<style xmlns="http://www.w3.org/1999/html">
    .layui-form-label {
        width: 100px;
    }
    .layui-input-block {
        margin-left: 130px;
    }
    .import {
        opacity: 0;
        position: absolute;
        width: 69px;
        height: 38px;
        margin-left: -10px;
    }
    .companyFormPhotos {
        margin-left: 50px;
        line-height: 38px;
        float: left;
        margin-right: 30px;
    }

    .companyFormPhotos img {
        height: 38px;
        width: auto;
        max-width: 200px;
    }

    .attachments{
        cursor: pointer;
        display: block;
        float: left;
        overflow:hidden;
        text-align: center;
        padding: 0 10px;
        width: 100px;
    }
    .option-item{
        overflow: hidden;
        color: #1E9FFF;
        text-align: center;
        height: 20px;
        line-height: 20px;
    }
    .preview{
        cursor: pointer;
        float: left;
    }
    .download{
        cursor: pointer;
        float: right;
    }
    .file-a{
        font-size: 12px;
        word-break: break-all;
        text-overflow: ellipsis;
        overflow: hidden;
        display: -webkit-box;
        -webkit-line-clamp: 1;
        -webkit-box-orient: vertical;
        margin-top: 5px;
    }
    .info_row{
        height: 30px;
        line-height: 30px;
    }
    #categorySearch xm-select{
        min-height: 32px;
        line-height: 32px;
        border-radius: 4px;
    }

    div[lay-id="agentAddDueTable"] .layui-table-box,
    div[lay-id="agentAddDueTable"] .layui-table-body,
    div[lay-id="agentAddDueTable"] .layui-table-cell {
        overflow: visible;
        padding: 0 1px;
    }

    div[lay-id="agentAddDueTable"] .layui-table-cell {
        height: auto;
        padding: 0 10px;
        word-break: break-word;
        white-space: pre-line;
    }

    .subjectDetailBox > div {
        margin-right: 10px !important;
    }

    [lay-filter="agentAddDueForm"] .open-details-box::-webkit-scrollbar {
        display: none;
        width: 0;
    }
</style>

<!-- 正文开始 -->
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-body">
            <!-- 头部操作栏 -->
            <div class="layui-form lay-header">
                <div class="toolbar">
                    <div class="layui-form-item lay-query-content">
                        <div class="lay-query-box">
                            <div class="query-lt">
                                <div class="layui-inline">
                                    <label class="layui-form-label">供应商名称：</label>
                                    <div class="layui-input-inline">
                                        <input type="text" class="layui-input" name="corporateName" placeholder="供应商名称" autocomplete="off"/>
                                    </div>
                                </div>

                                <div class="layui-inline">
                                    <label class="layui-form-label">供应商分类：</label>
                                    <div class="layui-input-inline">
                                        <input type="text" class="layui-input" name="categoryName" placeholder="供应商分类" autocomplete="off"/>
                                    </div>
                                </div>

                                <div class="layui-inline">
                                    <a lay-filter="formSubSearchLog" class="layui-btn icon-btn color-green" lay-submit
                                       type="button" layui-form-keyDownSearch="true">查询
                                    </a>
                                    <button class="layui-btn icon-btn color-white" lay-filter="resets" type="button"
                                            lay-submit>重置
                                    </button>
                                </div>
                            </div>
                            <div class="query-rt"></div>
                        </div>
                    </div>
                </div>
                <div class="lay-btn-rows">
                    <div class="lay-btn-box">
                        <div class="lay-btn-lt">
                              <button id="productDetailBtnImport" class="layui-btn icon-btn color-reseda">
                                <input id="uploaderInput" type="file" name="file" class="import" accept=".xls,.xlsx" />
                                导入
                            </button>
                            <button id="supplierInfoBtnAdd" class="layui-btn icon-btn color-reseda" type="button">添加</button>
                            <button id="syncSupplierInfoBtn" class="layui-btn icon-btn color-reseda" type="button">同步供应商</button>
                        </div>
                        <div class="lay-btn-rt">
                            <button id="SupplierContactsBtnDel" class="layui-btn icon-btn layui-btn-danger">批量删除</button>
                            <button id="productDetailBtnTemplate" class="layui-btn icon-btn color-green">模板下载</button>

                        </div>
                    </div>
                </div>
            </div>


            <!-- 表格 -->
            <table class="layui-table" id="supplierInfoTable" lay-filter="supplierInfoTable"></table>
        </div>
    </div>
</div>

<!-- 表格操作列 -->
<script type="text/html" id="supplierInfoTableBar">
    <!--<a class="layui-btn layui-btn-warm layui-btn-xs" lay-event="edit">修改</a>-->
    <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="details">详情</a>
    <!--<a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="due">尽调</a>-->
<!--    <a class="layui-btn layui-btn-xs" lay-event="pact">合同</a>-->
    <a class="layui-btn layui-btn-xs" lay-event="contacts">联系人</a>
    <!--<a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="order">订单</a>
    <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="settlement">结算</a>-->
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
</script>

<!-- 表单弹窗 -->
<script type="text/html" id="supplierInfoForm">
    <form lay-filter="supplierInfoForm" class="layui-form model-form supplierInfoForm">
        <input name="id" type="hidden"/>
        <div class="layui-form-item layui-row">
            <div class="layui-col-md4">
                <label class="layui-form-label">公司名称</label>
                <div class="layui-input-block">
                    <input name="corporateName" placeholder="请输入供应商公司名称" type="text" class="layui-input"
                           lay-verify="required" required autocomplete="off"/>
                </div>
            </div>
            <div class="layui-col-md4" >
                <label class="layui-form-label">供应商编码</label>
                <div class="layui-input-block">
                    <input name="code" placeholder="请输入供应商编码" required lay-verify="required" type="text" class="layui-input" autocomplete="off"/>
                </div>
            </div>

       <!--     <div class="layui-col-md4">
                <label class="layui-form-label">供应商编码</label>
                <div class="layui-input-block">
                    <input name="code" placeholder="请输入供应商编码" type="text" class="layui-input" autocomplete="off"/>
                </div>
            </div>-->

            <div class="layui-col-md4" style="display: flex;">
                <label class="layui-form-label">供应商级别</label>
                <div class="layui-input-block" style="margin: 0 10px 0 0; flex: 1;">
                    <select name="levelId" lay-verify="required" required id="levelId"></select>
                </div>
                <div class="layui-form-mid layui-word-aux" style="margin-right: 0;">
                    <a href="#/purchase/supplierLevel" class="layui-btn layui-btn-xs" ew-event="closeDialog">
                        <i class="layui-icon layui-icon-addition"></i>
                    </a>
                </div>
            </div>
        </div>
        <div class="layui-form-item layui-row">
            <div class="layui-col-md4" style="display: flex;">
                <label class="layui-form-label">供应商分类</label>
                <input name="categoryId" type="hidden" lay-verify="categoryId" lay-verify="required"/>
                <div class="layui-input-block" id="selectCategory" style="margin: 0 10px 0 0; flex: 1;">
                </div>
                <div class="layui-form-mid layui-word-aux" style="margin-right: 0;">
                    <a href="#/purchase/supplierCategory" class="layui-btn layui-btn-xs" ew-event="closeDialog">
                        <i class="layui-icon layui-icon-addition"></i>
                    </a>
                </div>
            </div>
            <div class="layui-col-md4">
                <label class="layui-form-label">证件号码</label>
                <div class="layui-input-block">
                    <input name="certificateNumber" placeholder="请输入组织机构代码证号" type="text" class="layui-input" required lay-verify="required" autocomplete="off"/>
                </div>
            </div>
            <div class="layui-col-md4">
                <label class="layui-form-label">营业执照</label>
                <div class="layui-input-block">
                    <div id="btnUploadCredentials_path" class="uploadImgStyle"></div>
                    <div id="btnUploadCredentials" class="layui-btn" style="float: left;"><i class="layui-icon">&#xe681;</i>上传
                    </div>
                    <input name="certificatePic" type="hidden" class="layui-input" lay-verify="" id="certificatePic"/>
                </div>
            </div>
        </div>
        <div class="layui-form-item layui-row">
            <div class="layui-col-md4">
                <label class="layui-form-label">收款银行</label>
                <div class="layui-input-block">
                    <input name="bankName" placeholder="请输入收款银行" type="text" class="layui-input" autocomplete="off"
                    />
                </div>
            </div>
            <div class="layui-col-md4">
                <label class="layui-form-label">收款银行账户</label>
                <div class="layui-input-block">
                    <input name="bankAccount" placeholder="请输入收款户号全称" type="text" class="layui-input" autocomplete="off"
                    />
                </div>
            </div>
            <!-- <div class="layui-col-md4">
                <label class="layui-form-label">收款银行账号</label>
                <div class="layui-input-block">
                    <input name="bankNumber" placeholder="请输入收款银行账号" type="text" class="layui-input" autocomplete="off"
                    />
                </div>
            </div> -->
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">开户许可证</label>
            <div class="layui-input-block">
                <div id="btnUploadDviceAppendix_path" class="uploadImgStyle"></div>
                <div id="btnUploadDviceAppendix" class="layui-btn" style="float: left;"><i
                        class="layui-icon">&#xe681;</i>上传
                </div>
                <input name="openingPermitPic" type="hidden" class="layui-input" lay-verify="" id="openingPermitPic"/>
            </div>
        </div>
        <div class="layui-form-item layui-row">
            <div class="layui-col-md4">
                <label class="layui-form-label">省</label>
                <div class="layui-input-block">
                    <select name="provinceId" id="provinceId" lay-filter="provinceId"
                    ></select>
                </div>
            </div>
            <div class="layui-col-md4">
                <label class="layui-form-label">市</label>
                <div class="layui-input-block">
                    <select name="cityId" id="cityId" lay-filter="cityId" ></select>
                </div>
            </div>
            <div class="layui-col-md4">
                <label class="layui-form-label">区/县</label>
                <div class="layui-input-block">
                    <select name="areaId" id="areaId" lay-filter="areaId" ></select>
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">联系地址</label>
            <div class="layui-input-block">
                <input name="contactAddress" placeholder="请输入联系地址" type="text" class="layui-input" autocomplete="off"
                />
            </div>
        </div>
        <div class="layui-form-item layui-row">
            <div class="layui-col-md4">
                <label class="layui-form-label">业务联系人</label>
                <div class="layui-input-block">
                    <input name="businessContact" placeholder="请输入业务联系人" type="text" class="layui-input" autocomplete="off"
                    />
                </div>
            </div>
            <div class="layui-col-md4">
                <label class="layui-form-label">财务联系人</label>
                <div class="layui-input-block">
                    <input name="financialContact" placeholder="请输入财务联系人" type="text" class="layui-input" autocomplete="off"
                    />
                </div>
            </div>
            <div class="layui-col-md4">
                <label class="layui-form-label">法定代表人</label>
                <div class="layui-input-block">
                    <input name="legalPerson" placeholder="请输入法定代表人" type="text" class="layui-input" autocomplete="off"
                    />
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">备注描述</label>
            <div class="layui-input-block">
                <input name="remark" placeholder="请输入备注描述" type="text" class="layui-input" autocomplete="off"/>
            </div>
        </div>
        <div class="layui-form-item text-right">
            <button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog" id="cancel">取消</button>
            <button class="layui-btn" lay-filter="supplierInfoFormSubmit" lay-submit id="supplierInfoFormSubmit">保存
            </button>
        </div>
    </form>
</script>
<!--<script type="text/html" id="supplierInfoForm">
    <form lay-filter="supplierInfoForm" class="layui-form model-form">
        <input name="id" type="hidden"/>
        <div class="layui-form-item">
            <label class="layui-form-label">供应商公司名称</label>
            <div class="layui-input-block">
                <input name="corporateName" placeholder="请输入供应商公司名称" type="text" class="layui-input" lay-verify="required" required/>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">供应商编码</label>
            <div class="layui-input-block">
                <input name="code" placeholder="请输入供应商编码" type="text" class="layui-input" lay-verify="required" required/>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">供应商级别</label>
            <div class="layui-input-block">
                <input name="levelName" placeholder="请输入供应商级别" type="text" class="layui-input" lay-verify="required" required/>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">供应商分类</label>
            <div class="layui-input-block">
                <input name="categoryName" placeholder="请输入供应商分类" type="text" class="layui-input" lay-verify="required" required/>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">来源</label>
            <div class="layui-input-block">
                <select name="sourceType">
                        <option value="backstage">后台添加</option>
                        <option value="website">官网申请</option>
                        <option value="platform">平台申请</option>
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">状态</label>
            <div class="layui-input-block">
                <select name="status">
                        <option value="pending">待审核</option>
                        <option value="pass">审核通过</option>
                        <option value="refuse">审核不通过</option>
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">审核人</label>
            <div class="layui-input-block">
                <input name="auditor" placeholder="请输入审核人" type="text" class="layui-input" lay-verify="required" required/>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">证件号码</label>
            <div class="layui-input-block">
                <input name="certificateNumber" placeholder="请输入证件号码" type="text" class="layui-input" lay-verify="required" required/>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">营业执照</label>
            <div class="layui-input-block">
                <div id="btnUploadCredentials_path" class="uploadImgStyle"></div>
                <div id="btnUploadCredentials" class="layui-btn" style="float: left;"><i class="layui-icon">&#xe681;</i>上传</div>
                <input name="certificatePic" type="hidden" class="layui-input" lay-verify="" id="certificatePic"/>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">收款银行</label>
            <div class="layui-input-block">
                <input name="bankName" placeholder="请输入收款银行" type="text" class="layui-input" lay-verify="required" required/>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">收款银行账户</label>
            <div class="layui-input-block">
                <input name="bankAccount" placeholder="请输入收款银行账户" type="text" class="layui-input" lay-verify="required" required/>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">收款银行账号</label>
            <div class="layui-input-block">
                <input name="bankNumber" placeholder="请输入收款银行账号" type="text" class="layui-input" lay-verify="required" required/>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">开户许可证</label>
            <div class="layui-input-block">
                <div id="btnUploadDviceAppendix_path" class="uploadImgStyle"></div>
                <div id="btnUploadDviceAppendix" class="layui-btn" style="float: left;"><i class="layui-icon">&#xe681;</i>上传</div>
                <input name="openingPermitPic" type="hidden" class="layui-input" lay-verify="" id="openingPermitPic"/>
            </div>
        </div>
        <div class="layui-col-xs4">
            <label class="layui-form-label">省</label>
            <div class="layui-input-block">
                <select name="provinceId" id="provinceId" lay-filter="provinceId" lay-verify="required"
                        required></select>
            </div>
        </div>
        <div class="layui-col-xs4">
            <label class="layui-form-label">市</label>
            <div class="layui-input-block">
                <select name="cityId" id="cityId" lay-filter="cityId" lay-verify="required" required></select>
            </div>
        </div>
        <div class="layui-col-xs4">
            <label class="layui-form-label">区/县</label>
            <div class="layui-input-block">
                <select name="areaId" id="areaId" lay-filter="areaId" lay-verify="required" required></select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">联系地址</label>
            <div class="layui-input-block">
                <input name="contactAddress" placeholder="请输入联系地址" type="text" class="layui-input" lay-verify="required" required/>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">业务联系人</label>
            <div class="layui-input-block">
                <input name="businessContact" placeholder="请输入业务联系人" type="text" class="layui-input" lay-verify="required" required/>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">财务联系人</label>
            <div class="layui-input-block">
                <input name="financialContact" placeholder="请输入财务联系人" type="text" class="layui-input" lay-verify="required" required/>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">法定代表人</label>
            <div class="layui-input-block">
                <input name="legalPerson" placeholder="请输入法定代表人" type="text" class="layui-input" lay-verify="required" required/>
            </div>
        </div>
        <div class="layui-form-item text-right">
            <button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog" id="cancel">取消</button>
            <button class="layui-btn" lay-filter="supplierInfoFormSubmit" lay-submit id="supplierInfoFormSubmit">保存</button>
        </div>
    </form>
</script>-->



<!--联系人-->
<script type="text/html" id="contactsForm">
    <div class="layui-form open-form">
        <div class="open-model">
            <div class="open-auto">
                <!-- 头部操作栏 -->
                <div class="lay-header">
                    <div class="toolbar">
                        <div class="layui-form-item lay-query-content">
                            <div class="lay-query-box">
                                <div class="query-lt">
                                    <!--<div class="layui-inline">
                                        <label class="layui-form-label">供应商名称:</label>
                                        <div class="layui-input-inline">
                                            <input type="text" class="layui-input" name="corporateName" placeholder="供应商名称">
                                        </div>
                                    </div>-->
                                    <div class="layui-inline">
                                        <label class="layui-form-label">联系人姓名：</label>
                                        <div class="layui-input-inline">
                                            <input type="text" class="layui-input" name="contactName" placeholder="联系人姓名" autocomplete="off"/>
                                        </div>
                                    </div>
                                    <div class="layui-inline">
                                        <label class="layui-form-label">联系人电话：</label>
                                        <div class="layui-input-inline">
                                            <input type="text" class="layui-input" name="phoneNumber" placeholder="联系人电话" autocomplete="off"/>
                                        </div>
                                    </div>
                                </div>
                                <div class="query-rt">
                                    <div class="layui-inline">
                                        <a lay-filter="formSubSearchLogContacts" class="layui-btn color-green" lay-submit
                                           type="button">查询
                                        </a>
                                        <button class="layui-btn color-white" lay-filter="resetsContacts" type="button"
                                                lay-submit>重置
                                        </button>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="lay-btn-rows">
                        <div class="lay-btn-box">
                            <div class="lay-btn-lt">
                                <button id="supplierContactsBtnAdd" class="layui-btn icon-btn color-reseda">添加</button>
                                <button id="SupplierContactsBtnDelContacts" class="layui-btn icon-btn layui-btn-danger">批量删除</button>
                            </div>
                            <div class="lay-btn-rt">

                            </div>
                        </div>
                    </div>
                </div>
                <!-- 表格 -->
                <table class="layui-table" id="supplierContactsTable" lay-filter="supplierContactsTable"></table>
            </div>
            <div class="layui-form-item text-right">
                <button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog">取消</button>
            </div>
        </div>
    </div>
</script>

<!-- 联系人表格操作列 -->
<script type="text/html" id="supplierContactsTableBar">
    <a class="layui-btn layui-btn-xs" lay-event="editContacts">修改</a>
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="delContacts">删除</a>
</script>

<!-- 联系人表单弹窗 -->
<script type="text/html" id="supplierContactsForm">
    <form lay-filter="supplierContactsForm" class="layui-form model-form">
        <input name="id" type="hidden"/>
        <div class="layui-form-item" >
            <label class="layui-form-label">供应商公司名称</label>
            <div class="layui-input-inline">
                <select name="corporateId" lay-verify="required" required id="corporateId"></select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">联系人姓名</label>
            <div class="layui-input-block">
                <input name="contactName" placeholder="请输入联系人姓名" type="text" class="layui-input" lay-verify="required" required autocomplete="off"/>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">联系人电话</label>
            <div class="layui-input-block">
                <input name="phoneNumber" placeholder="请输入联系人电话" type="text" class="layui-input" lay-verify="required" required autocomplete="off"/>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">职务</label>
            <div class="layui-input-block">
                <input name="job" placeholder="请输入职务" type="text" class="layui-input" lay-verify="required" required autocomplete="off"/>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">身份证号码</label>
            <div class="layui-input-block">
                <input name="cardNo" placeholder="请输入身份证号码" type="text" class="layui-input" autocomplete="off"/>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">证件扫描件</label>
            <div class="layui-input-block">
                <div id="btnUploadCredentials_pathContacts" class="uploadImgStyle"></div>
                <div id="btnUploadCredentialsContacts" class="layui-btn" style="float: left;"><i class="layui-icon">&#xe681;</i>上传</div>
                <input name="cardPic" type="hidden" class="layui-input" lay-verify="" id="cardPic"/>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">名片扫描件</label>
            <div class="layui-input-block">
                <div id="btnUploadDviceAppendix_pathContacts" class="uploadImgStyle"></div>
                <div id="btnUploadDviceAppendixContacts" class="layui-btn" style="float: left;"><i class="layui-icon">&#xe681;</i>上传</div>
                <input name="callingCardPic" type="hidden" class="layui-input" lay-verify="" id="callingCardPic"/>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-col-xs4">
                <label class="layui-form-label">省</label>
                <div class="layui-input-block">
                    <select name="provinceId" id="provinceId" lay-filter="provinceId"></select>
                </div>
            </div>
            <div class="layui-col-xs4">
                <label class="layui-form-label">市</label>
                <div class="layui-input-block">
                    <select name="cityId" id="cityId" lay-filter="cityId"></select>
                </div>
            </div>
            <div class="layui-col-xs4">
                <label class="layui-form-label">区/县</label>
                <div class="layui-input-block">
                    <select name="areaId" id="areaId" lay-filter="areaId"></select>
                </div>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">联系地址</label>
            <div class="layui-input-block">
                <input name="contactAddress" placeholder="请输入联系地址" type="text" class="layui-input" autocomplete="off"/>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">邮箱地址</label>
            <div class="layui-input-block">
                <input name="email" placeholder="请输入邮箱地址" type="text" class="layui-input" autocomplete="off"/>
            </div>
        </div>
        <div class="layui-form-item text-right">
            <button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog">取消</button>
            <button class="layui-btn" lay-filter="supplierContactsFormSubmit" lay-submit>保存</button>
        </div>
    </form>
</script>


<!-- 尽调弹窗 -->
<script type="text/html" id="agentDueForm">
    <div class="layui-fluid">
        <div class="layui-card">
            <div class="layui-card-body">
                <!-- 头部操作栏 -->
                <!--<div class="layui-form toolbar">
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <button id="agentDueBtnAdd" class="layui-btn icon-btn"><i class="layui-icon">&#xe654;</i>添加供应商尽调记录信息</button>
                        </div>
                    </div>
                </div>-->
                <!-- 表格 -->
                <table class="layui-table" id="agentDueTable" lay-filter="agentDueTable"></table>
            </div>
        </div>
    </div>
</script>

<!--尽调添加弹窗 -->
<script type="text/html" id="agentAddDueForm">
    <form lay-filter="agentAddDueForm" class="layui-form model-form"
          style="padding: 5px 30px 0 30px;height: calc(100% - 5px);overflow: hidden;">
        <div class="open-details-box"
             style="height: calc(100% - 70px);overflow: auto;margin-bottom: 15px;">
            <div class="layui-form-item">
                <table class="layui-table" id="agentAddDueTable" lay-filter="agentAddDueTable"
                       style="margin: 0"></table>
            </div>
        </div>
        <div class="layui-form-item text-right">
            <button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog">取消</button>
            <!--<button id="supplierDueFormSubmit" class="layui-btn" lay-filter="agentAddDueFormSubmit" lay-submit>保存
            </button>-->
        </div>
    </form>
</script>
<!-- 表格操作列 -->
<script type="text/html" id="agentDueTableBar">

    <a class="layui-btn layui-btn-xs" lay-event="dueDetail">详情</a>

</script>




<!-- 合同弹窗 -->
<script type="text/html" id="contract">
    <div class="layui-fluid">
        <div class="layui-card">
            <div class="layui-card-body">
                <!-- 头部操作栏 -->
                <div class="layui-form lay-header">
                    <div class="toolbar">
                        <div class="layui-form-item lay-query-content">
                            <div class="lay-query-box">
                                <div class="query-lt">
                                    <div class="layui-inline" id="categorySearch">
                                        <input name="contractCategoryId" type="hidden" />
                                        <div class="layui-input-inline mr0" id="selContractCategory">
                                        </div>
                                    </div>
                                    <div class="layui-inline">
                                        <div class="layui-input-inline mr0">
                                            <input name="companyName" class="layui-input" type="text" placeholder="请输入签约主体名称" autocomplete="off"/>
                                        </div>
                                    </div>
                                    <div class="layui-inline">
                                        <div class="layui-input-inline mr0">
                                            <input name="code" class="layui-input" type="text" placeholder="请输入合同编号" autocomplete="off"/>
                                        </div>
                                    </div>
                                    <div class="layui-inline">
                                        <div class="layui-input-inline mr0">
                                            <input name="contactName" class="layui-input" type="text" placeholder="请输入供应商名称" autocomplete="off"/>
                                        </div>
                                    </div>
                                    <div class="layui-inline">
                                        <div class="layui-input-inline mr0">
                                            <input name="createTime" id="pTime" class="layui-input date-icon" type="text"
                                                   placeholder="请选择时间段" style="width: 200px"/>
                                        </div>
                                        <input name="startCreateTime" id="sTime" type="hidden"/>
                                        <input name="endCreateTime" id="eTime" type="hidden"/>
                                    </div>
                                </div>
                                <div class="query-rt">
                                    <div class="layui-inline">
                                        <button class="layui-btn icon-btn color-green" lay-filter="formSubSearchLog" lay-submit>查询</button>
                                        <button class="layui-btn icon-btn color-white" lay-filter="resets" lay-submit>重置</button>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="lay-btn-rows">
                        <div class="lay-btn-box">
                            <div class="lay-btn-lt">
                                <button id="contractBtnAdd" class="layui-btn icon-btn color-reseda">添加</button>
                            </div>
                            <div class="lay-btn-rt">

                            </div>
                        </div>
                    </div>
                </div>
                <!-- 表格 -->
                <table class="layui-table" id="contractTable" lay-filter="contractTable"></table>
            </div>
        </div>
    </div>
</script>

<!-- 合同表格操作列 -->
<script type="text/html" id="contractTableBar">
    <a class="layui-btn layui-btn-xs" lay-event="view">详情</a>
    <a class="layui-btn layui-btn-warm layui-btn-xs" lay-event="changeRecord">变更记录</a>
    {{# if(d.status == 'hasSign'){ }}
    <a class="layui-btn layui-btn-xs" lay-event="relatedProduct">物料</a>
    {{# } }}
</script>

<script type="text/html" id="viewAttachmentBar">
    <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="viewAttachment">查看附件</a>
</script>

<!-- 合同表单弹窗 -->
<script type="text/html" id="contractForm">
    <form lay-filter="contractForm" class="layui-form model-form">
        <input name="id" type="hidden"/>
        <div class="layui-form-item">
            <label class="layui-form-label"><span style="color: red">*</span>合同主体类型</label>
            <div class="layui-input-block">
                <select name="type" disabled></select>
            </div>
        </div>
        <div class="layui-form-item" id="PID">
            <label class="layui-form-label"><span style="color: red">*</span>合同分类</label>
            <input name="contractCategoryId" type="hidden" lay-verify="contractCategoryId" />
            <div class="layui-input-block" id="selectContractCategory">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label"><span style="color: red">*</span>签约主体名称</label>
            <div class="layui-input-block">
                <select name="subjectId" disabled></select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label"><span style="color: red">*</span>合同名称</label>
            <div class="layui-input-block">
                <input name="name" placeholder="请输入合同名称" type="text" class="layui-input" maxlength="200" lay-verify="required" required autocomplete="off"/>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label"><span style="color: red">*</span>合同编号</label>
            <div class="layui-input-block">
                <input name="code" placeholder="请输入合同编号" type="text" class="layui-input" maxlength="200" lay-verify="required" required autocomplete="off"/>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label"><span style="color: red">*</span>供应商签约人</label>
            <div class="layui-input-block">
                <select name="contactsId" lay-verify="required" required lay-search></select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label"><span style="color: red">*</span>我方签约人</label>
            <div class="layui-input-block">
                <select name="contractor" lay-verify="required" required lay-search></select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label"><span style="color: red">*</span>信息审批人</label>
            <div class="layui-input-block">
                <select name="approver" lay-verify="required" required lay-search></select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label"><span style="color: red">*</span>签约金额</label>
            <div class="layui-input-block">
                <input name="amount" placeholder="请输入签约金额" type="text" class="layui-input" lay-verify="required|decimal" required autocomplete="off"/>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label"><span style="color: red">*</span>上传附件</label>
            <div class="layui-input-block">
                <div id="addDevicePicBtn" class="layui-btn" style="float: left;margin-left: 3px"><i class="layui-icon">&#xe681;</i>上传PDF文件
                </div>
                <div id="addHeaderImg" class="companyFormPhotos"></div>
                <input name="attachment" id="attachment" type="hidden" class="layui-input" lay-verify="attachment" />
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">备注</label>
            <div class="layui-input-block">
                <textarea name="remark" placeholder="请输入备注" maxlength="200" class="layui-textarea" autocomplete="off"></textarea>
            </div>
        </div>
        <div class="layui-form-item text-right">
            <button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog">取消</button>
            <button class="layui-btn" lay-filter="contractFormSubmit" lay-submit>保存</button>
        </div>
    </form>
</script>

<!-- 合同详情 -->
<script type="text/html" id="contractView">
    <div style="padding: 20px;">
        <table class="layui-table">
            <thead>
            <tr>
                <th style="width: 35%;">合同信息</th>
                <th>合同PDF预览内容</th>
            </tr>
            </thead>
            <tbody>
            <tr>
                <td id="contractInfo">

                </td>
                <td>
                    <div id="attachmentName" style="margin-bottom: 10px; font-size: 16px;">合同附件：</div>
                    <div id="example1" style="height: 500px;"></div>
                </td>
            </tr>
            </tbody>
        </table>
    </div>
</script>

<!-- 合同审核 -->
<script type="text/html" id="contractAuditForm">
    <form lay-filter="contractAuditForm" class="layui-form model-form">
        <input name="id" type="hidden"/>
        <div class="layui-form-item">
            <label class="layui-form-label">审核意见</label>
            <div class="layui-input-block">
                <textarea name="auditOpinion" placeholder="请输入审核意见" maxlength="200" class="layui-textarea" autocomplete="off"></textarea>
            </div>
        </div>
        <div class="layui-form-item text-right">
            <button class="layui-btn" data-status="success" lay-filter="contractAuditFormSubmit" lay-submit>审核通过</button>
            <button class="layui-btn layui-btn-danger" data-status="fail" lay-filter="contractAuditFormSubmit" lay-submit>审核不通过</button>
        </div>
    </form>
    <div style="padding: 20px;">
        <table class="layui-table">
            <thead>
            <tr>
                <th style="width: 35%;">合同信息</th>
                <th>合同PDF预览内容</th>
            </tr>
            </thead>
            <tbody>
            <tr>
                <td id="contractInfo">

                </td>
                <td>
                    <div id="attachmentName" style="margin-bottom: 10px; font-size: 16px;">合同附件：</div>
                    <div id="example1" style="height: 500px;"></div>
                </td>
            </tr>
            </tbody>
        </table>
    </div>
</script>

<!-- 合同信息 -->
<script type="text/html" id="contractInfoHtml">
    <div class="info_row">供应商名称：{{d.companyName}}</div>
    <div class="info_row">合同名称：{{d.name}}</div>
    <div class="info_row">合同编号：{{d.code}}</div>
    <div class="info_row">供应商签约人：{{d.contactName}}</div>
    <div class="info_row" id="contractorName">我方签约人：{{d.contractorName}}</div>
    <div class="info_row">签约时间：{{d.signingTime ? d.signingTime : ""}}</div>
    <div class="info_row">交货时间：{{d.deliveryTime ? d.deliveryTime : ""}}</div>
    <div class="info_row">备注信息：{{d.remark}}</div>
    <div class="info_row">合同金额：{{d.amount}}</div>
    <div style="overflow: hidden; padding: 5px 0;">
        <div style="float: left;">合同附件：</div>
        {{# var attachment = "";
        if(d.attachment){
        attachment = d.attachment.substring(d.attachment.lastIndexOf("/")+1);
        }
        var time = timeStamp2String(d.createTime);
        }}
        <div class="attachments">
            <div onclick="previewFile('{{attachment}}', '{{d.attachment}}');">
                <img src="../../../admin/assets/images/attachmentsIcon/pdf.png">
                <span class="file-a">{{attachment}}</span>
                <span class="file-a">{{time}}</span>
            </div>
        </div>
    </div>
    <div class="info_row">合同存放地点：{{d.address ? d.address : ""}}</div>
    <div class="info_row" id="keeperName">合同保管员：{{d.keeperName ? d.keeperName : ""}}</div>
    <!--<div class="info_row">合同状态：{{d.statusDesc}}</div>-->
    <div class="info_row" id="approverName">信息审批人：{{d.approverName ? d.approverName : ""}}</div>
    <div class="info_row">审核结果：{{d.statusDesc ? d.statusDesc : ""}}</div>
    <div class="info_row">审核意见备注：{{d.auditOpinion ? d.auditOpinion : ""}}</div>
</script>

<!-- 查看附件 -->
<script type="text/html" id="viewAttachmentHtml">
    <div id="example1" style="height: 100%;"></div>
</script>

<!-- 合同变更记录弹窗 -->
<script type="text/html" id="contractChangeRecord">
    <div class="layui-card">
        <div class="layui-card-body" id="changeRecord">
            <!-- 头部操作栏 -->
            <div class="layui-form lay-header">
                <div class="toolbar">
                    <div class="layui-form-item lay-query-content">
                        <div class="lay-query-box">
                            <div class="query-lt">
                                <div class="layui-inline">
                                    <label class="layui-form-label w-auto">合同编号：</label>
                                    <div class="layui-input-inline mr0">
                                        <input name="code" class="layui-input" type="text" placeholder="请输入编号" autocomplete="off"/>
                                    </div>
                                </div>
                            </div>
                            <div class="query-rt">
                                <div class="layui-inline">
                                    <button class="layui-btn icon-btn color-green" lay-filter="contractChangeRecordFormSubSearchLog" lay-submit>查询</button>
                                    <button class="layui-btn icon-btn color-white" lay-filter="contractChangeRecordResets" lay-submit>重置</button>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="lay-btn-rows" id="opBtn">
                    <div class="lay-btn-box">
                        <div class="lay-btn-lt">
                            <button id="contractChangeRecordBtnAdd" class="layui-btn icon-btn color-reseda">添加合同变更记录</button>
                        </div>
                        <div class="lay-btn-rt">

                        </div>
                    </div>
                </div>
            </div>
            <!-- 表格 -->
            <table class="layui-table" id="contractChangeRecordTable" lay-filter="contractChangeRecordTable"></table>
        </div>
    </div>
</script>

<!-- 添加合同变更记录表单弹窗 -->
<script type="text/html" id="contractChangeRecordForm">
    <form lay-filter="contractChangeRecordForm" class="layui-form model-form">
        <input name="id" type="hidden"/>
        <div class="layui-form-item" id="PID">
            <label class="layui-form-label"><span style="color: red">*</span>请选择合同分类</label>
            <input name="contractCategoryId" type="hidden" lay-verify="contractCategoryId" />
            <div class="layui-input-block" id="selectContractCategory">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label"><span style="color: red">*</span>签约主体名称</label>
            <div class="layui-input-block">
                <input name="companyName" type="text" class="layui-input" style="border: 0;" readonly />
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label"><span style="color: red">*</span>合同名称</label>
            <div class="layui-input-block">
                <input name="name" placeholder="请输入合同名称" type="text" class="layui-input" maxlength="200" lay-verify="required" required autocomplete="off"/>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label"><span style="color: red">*</span>合同编号</label>
            <div class="layui-input-block">
                <input name="code" placeholder="请输入合同编号" type="text" class="layui-input" readonly maxlength="200" lay-verify="required" required autocomplete="off"/>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label"><span style="color: red">*</span>供应商签约人</label>
            <div class="layui-input-block">
                <select name="contactsId" lay-verify="required" required lay-search></select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label"><span style="color: red">*</span>我方签约人</label>
            <div class="layui-input-block">
                <select name="contractor" lay-verify="required" required lay-search></select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label"><span style="color: red">*</span>签约时间</label>
            <div class="layui-input-block">
                <input name="signingTime" id="signingTime" placeholder="请选择签约时间" type="text" class="layui-input" readonly lay-verify="required" required/>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label"><span style="color: red">*</span>信息审批人</label>
            <div class="layui-input-block">
                <select name="approver" lay-verify="required" required lay-search></select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">备注信息</label>
            <div class="layui-input-block">
                <textarea name="remark" placeholder="请输入备注信息" maxlength="200" class="layui-textarea" autocomplete="off"></textarea>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label"><span style="color: red">*</span>上传附件</label>
            <div class="layui-input-block">
                <div id="addDevicePicBtn" class="layui-btn" style="float: left;margin-left: 3px"><i class="layui-icon">&#xe681;</i>上传PDF文件
                </div>
                <div id="addHeaderImg" class="companyFormPhotos"></div>
                <input name="attachment" id="attachment" type="hidden" class="layui-input" lay-verify="attachment" />
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label"><span style="color: red">*</span>签约金额</label>
            <div class="layui-input-block">
                <input name="amount" placeholder="请输入签约金额" type="text" class="layui-input" lay-verify="required|decimal" required autocomplete="off"/>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label"><span style="color: red">*</span>是否最终版</label>
            <div class="layui-input-block">
                <input name="isFinal" type="checkbox" lay-skin="switch" lay-filter="isFinal" lay-text="是|否"/>
            </div>
        </div>
        <div id="content" style="display: none;">
            <div class="layui-form-item">
                <label class="layui-form-label"><span style="color: red">*</span>交货时间</label>
                <div class="layui-input-block">
                    <input name="deliveryTime" id="deliveryTime" placeholder="请选择交货时间" type="text" class="layui-input" readonly />
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label"><span style="color: red">*</span>合同存放地点</label>
                <div class="layui-input-block">
                    <input name="address" placeholder="请输入合同存放地点" type="text" class="layui-input" />
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label"><span style="color: red">*</span>合同保管员</label>
                <div class="layui-input-block">
                    <select name="keeper" ></select>
                </div>
            </div>
        </div>
        <div class="layui-form-item text-right">
            <button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog">取消</button>
            <button class="layui-btn" lay-filter="contractChangeRecordFormSubmit" lay-submit>保存</button>
        </div>
    </form>
</script>

<!-- 合同变更记录表格操作列 -->
<script type="text/html" id="contractChangeRecordTableBar">
    {{# if(d.status == 'stayAudit' || d.status == 'fail'){ }}
    <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="edit">修改</a>
    {{# } }}
    <a class="layui-btn layui-btn-xs" lay-event="view">详情</a>
    {{# if(d.status == 'stayAudit'){ }}
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="audit">审核</a>
    {{# } }}
    {{# if(d.status == 'success'){ }}
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="final">终版</a>
    {{# } }}
</script>

<!-- 终版弹窗 -->
<script type="text/html" id="contractFinalForm">
    <form lay-filter="contractFinalForm" class="layui-form model-form">
        <input name="id" type="hidden"/>
        <div class="layui-form-item">
            <label class="layui-form-label"><span style="color: red">*</span>交货时间</label>
            <div class="layui-input-block">
                <input name="deliveryTime" id="deliveryTime" placeholder="请选择交货时间" type="text" class="layui-input" readonly lay-verify="required" required  />
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label"><span style="color: red">*</span>合同存放地点</label>
            <div class="layui-input-block">
                <input name="address" placeholder="请输入合同存放地点" type="text" class="layui-input" lay-verify="required" required  />
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label"><span style="color: red">*</span>合同保管员</label>
            <div class="layui-input-block">
                <select name="keeper" lay-verify="required" required lay-search></select>
            </div>
        </div>
        <div class="layui-form-item text-right">
            <button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog">取消</button>
            <button class="layui-btn" lay-filter="contractFinalFormSubmit" lay-submit>确认终版</button>
        </div>
    </form>
</script>

<!-- 关联物料 -->
<script type="text/html" id="contractRelatedProduct">
    <div class="layui-card">
        <div class="layui-card-body">
            <!-- 表格 -->
            <table class="layui-table" id="contractRelatedProductContractTable" lay-filter="contractRelatedProductContractTable"></table>

            <!-- 表格 -->
            <table class="layui-table" id="contractRelatedProductTable" lay-filter="contractRelatedProductTable"></table>
        </div>
    </div>
</script>

<!-- 联系供应商 -->
<script type="text/html" id="customerPhoneBar">
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="viewCustomerPhone">联系供应商</a>
</script>

<!-- js部分 -->
<script type="text/javascript" src="../../../admin/assets/js/pdfobject.min.js"></script>
<script type="text/javascript" src="../../../admin/assets/js/jsencrypt.min.js"></script>
<script>
    var $,config;

    // 预览文件
    function previewFile(realName, url) {
        $("#attachmentName").text("合同附件："+realName);
        PDFObject.embed(url, "#example1");
    }

    //在Jquery里格式化Date日期时间数据
    function timeStamp2String(time){
        var datetime = new Date(time);
        var year = datetime.getFullYear();
        var month = datetime.getMonth() + 1 < 10 ? "0" + (datetime.getMonth() + 1) : datetime.getMonth() + 1;
        var date = datetime.getDate() < 10 ? "0" + datetime.getDate() : datetime.getDate();
        var hour = datetime.getHours()< 10 ? "0" + datetime.getHours() : datetime.getHours();
        var minute = datetime.getMinutes()< 10 ? "0" + datetime.getMinutes() : datetime.getMinutes();
        var second = datetime.getSeconds()< 10 ? "0" + datetime.getSeconds() : datetime.getSeconds();
        // return year + "-" + month + "-" + date+" "+hour+":"+minute+":"+second;
        return year + "年" + month + "月" + date + "日";
    }

    layui.use(['layer', 'form', 'table', 'admin', 'upload', 'laytpl', 'laydate'], function () {
        $ = layui.jquery;
        var layer = layui.layer;
        var form = layui.form;
        var table = layui.table;
        var config = layui.config;
        var admin = layui.admin;
        var upload = layui.upload;
        var laytpl = layui.laytpl;
        var laydate = layui.laydate;

        // 渲染表格
        var insTb = table.render({
            elem: '#supplierInfoTable',
            url: config.base + 'enterprise/purchase/admin/supplierInfoPass/list',
            toolbar: true,
            defaultToolbar: ["filter"],
            page: true,
            cellMinWidth: 100,
            cols: [[
                {type: 'checkbox'}
                ,{field: 'corporateName', sort: false, title: '供应商公司名称'}
                ,{field: 'code', sort: true, title: '供应商编码'}
                ,{field: 'levelName', sort: false, title: '供应商级别'}
                ,{field: 'categoryName', sort: false, title: '供应商分类'}
                ,{field: 'sourceTypeDesc', sort: false, title: '来源'}
                ,{field: 'remark', sort: false, title: '备注描述'}
                ,{field: 'statusDesc', sort: false, title: '状态'}
                ,{field: 'auditor', sort: true, title: '审核人'}
                ,{field: 'auditTime', sort: false, title: '审核时间'}
                ,{align: 'center', toolbar: '#supplierInfoTableBar', title: '操作', width: 280}
            ]],
        });

        var flag=true;
        // 工具条点击事件
        table.on('tool(supplierInfoTable)', function (obj) {
            var data = obj.data;
            if (obj.event === 'edit') { //修改
                flag=false;
                showEditModel(data);
            } else if (obj.event === 'del') { // 删除
                doDelete(obj);
            }else if (obj.event === 'details') { // 详情
                flag=true;
                showEditModel(data);
            }else if (obj.event === 'contacts') { // 联系人
                showContacts(obj);
            }else if (obj.event === 'due') { // 尽调
                doDue(obj);
            }else if (obj.event === 'pact') { // 合同
                showPact(data);
            }
        });

        //监听排序
        table.on('sort(supplierInfoTable)', function(obj){
            table.reload('supplierInfoTable', {
                initSort: obj
                ,where: {
                    sort: obj.field
                    ,order: obj.type
                }
            });
        });

        // 添加按钮点击事件
        $('#supplierInfoBtnAdd').click(function () {
            // showEditModel1();
            showEditModel();
        });

        // 显示编辑弹窗
        function showEditModel(data) {
            admin.open({
                type: 1,
                area: '1280px',
                offset: '65px',
                title: data ? (flag ? '详情' : '修改') : '添加供应商',
                content: $('#supplierInfoForm').html(),
                success: function () {
                    //自定义验证规则
                    form.verify({
                        categoryId: function (value) {
                            if (value == "") {
                                return "请选择供应商分类";
                            }
                        }
                    })
                    if (data && !flag) {//修改
                        admin.reqSync('enterprisecab/area/admin/area/getProvince', {}, function (res) {
                            if (200 == res.code) {
                                loadSelectHtml(res.data, "请选择省份", "provinceId", 0);
                            }
                        }, 'GET', true);
                        admin.reqSync('enterprisecab/area/admin/area/getCity?parentId=' + data.provinceId, {}, function (res) {
                            if (200 == res.code) {
                                loadSelectHtml(res.data, "请选择城市", "cityId", 0);
                            }
                        }, 'GET', true);
                        admin.reqSync('enterprisecab/area/admin/area/getArea?parentId=' + data.cityId, {}, function (res) {
                            if (200 == res.code) {
                                loadSelectHtml(res.data, "请选择区/县", "areaId", 0);
                            }
                        }, 'GET', true);

                        //供应商级别
                        admin.reqSync('enterprise/purchase/admin/supplierLevel/list?page=1&limit=9999', {}, function (res) {
                            layer.closeAll('loading');
                            if (res.code == 200) {
                                loadSelectHtml(res.data, "请选择供应商级别", "levelId", 0)
                            }
                        }, 'GET');
                        //供应商分类
                        /* admin.reqSync('enterprise/purchase/admin/supplierCategory/list?page=1&limit=9999', {}, function (res) {
                             layer.closeAll('loading');
                             if (res.code == 200) {
                                 loadSelectHtml(res.data, "请选择供应商类别", "categoryId",0)
                             }
                         }, 'GET');*/
                        $("#btnUploadCredentials_path").html("<img src='" + data.certificatePic + "'/>")
                        $("#btnUploadDviceAppendix_path").html("<img src='" + data.openingPermitPic + "'/>")
                        layer.photos({
                            photos: '.uploadImgStyle'
                            , anim: 5 //0-6的选择，指定弹出图片动画类型，默认随机（请注意，3.0之前的版本用shift参数）
                        });
                        $('#code').css("display", "none")
                    } else if (data && flag) {//详情
                        admin.reqSync('enterprisecab/area/admin/area/getProvince', {}, function (res) {
                            if (200 == res.code) {
                                loadSelectHtml(res.data, "请选择省份", "provinceId", 0);
                            }
                        }, 'GET', true);

                        admin.reqSync('enterprisecab/area/admin/area/getCity?parentId=' + data.provinceId, {}, function (res) {
                            if (200 == res.code) {
                                loadSelectHtml(res.data, "请选择城市", "cityId", 0);
                            }
                        }, 'GET', true);

                        admin.reqSync('enterprisecab/area/admin/area/getArea?parentId=' + data.cityId, {}, function (res) {
                            if (200 == res.code) {
                                loadSelectHtml(res.data, "请选择区/县", "areaId", 0);
                            }
                        }, 'GET', true);


                        $("#btnUploadCredentials_path").html("<img src='" + data.certificatePic + "'/>")
                        $("#btnUploadDviceAppendix_path").html("<img src='" + data.openingPermitPic + "'/>")
                        layer.photos({
                            photos: '.uploadImgStyle'
                            , anim: 5 //0-6的选择，指定弹出图片动画类型，默认随机（请注意，3.0之前的版本用shift参数）
                        });
                        $('[lay-filter="supplierInfoForm"] input').attr("disabled", '');
                        $('[lay-filter="supplierInfoForm"] input').attr("placeholder", ' ');
                        $('[lay-filter="supplierInfoForm"] select').attr("disabled", '');


                        $('#supplierInfoFormSubmit').css("display", "none")
                        $('#cancel').css("display", "none")
                        $('#btnUploadCredentials').css("display", "none")
                        $('#btnUploadDviceAppendix').css("display", "none")

                        loadSelectHtml(data, data.categoryName, "categoryId");
                        loadSelectHtml(data, data.levelName, "levelId");
                    } else if (!data) {//添加
                        $('#code').css("display", "none")
                        //供应商级别
                        admin.reqSync('enterprise/purchase/admin/supplierLevel/list?page=1&limit=9999', {}, function (res) {
                            layer.closeAll('loading');
                            if (res.code == 200) {
                                loadSelectHtml(res.data, "请选择供应商级别", "levelId", 0)
                            }
                        }, 'GET');
                        //供应商分类
                        /*admin.reqSync('enterprise/purchase/admin/supplierCategory/list?page=1&limit=9999', {}, function (res) {
                            layer.closeAll('loading');
                            if (res.code == 200) {
                                loadSelectHtml(res.data, "请选择供应商类别", "categoryId",0)
                            }
                        }, 'GET');*/
                        var selectArea = function (city) {
                            admin.req('enterprisecab/area/admin/area/getArea?parentId=' + city, {}, function (res) {
                                layer.closeAll('loading');
                                if (200 == res.code) {
                                    loadSelectHtml(res.data, "请选择区/县", "areaId", 0);
                                }
                            }, 'GET');
                        }
                        var selectCity = function (province) {
                            admin.req('enterprisecab/area/admin/area/getCity?parentId=' + province, {}, function (res) {
                                layer.closeAll('loading');
                                if (200 == res.code) {
                                    loadSelectHtml(res.data, "请选择市", "cityId", 0);
                                }
                            }, 'GET');
                        }
                        // 获取省区域信息
                        admin.req('enterprisecab/area/admin/area/getProvince', {}, function (res) {

                            if (200 == res.code) {
                                loadSelectHtml(res.data, "请选择省份", "provinceId", 0);
                            }
                        }, 'GET', true);


                        form.on('select(provinceId)', function (data) {
                            $("#cityId").empty();
                            $('#areaId').empty();

                            // 获取市区域信息
                            if (data.value != '') {
                                selectCity(data.value);
                            }
                        });

                        form.on('select(cityId)', function (data) {
                            $('#areaId').empty();

                            // 获取区县区域信息
                            if (data.value != '') {
                                selectArea(data.value);
                            }
                        });


                    }


                    var json = {};
                    if (data && data.categoryId) {
                        json.selectId = data.categoryId;
                    }

                    admin.reqSync('enterprise/purchase/admin/supplierCategory/getTreeData', json, function (obj) {
                        TreeData = obj.data;
                        xmSelect.render({
                            el: '#selectCategory',
                            model: {label: {type: 'text'}},
                            radio: true,
                            clickClose: true,
                            filterable: true,
                            tree: {
                                show: true,
                                strict: false,
                                expandedKeys: [-1],
                            },
                            tips: '顶级分类',
                            height: 'auto',
                            data() {
                                return TreeData;
                            },
                            on: function (data) {
                                //被选中的select的id,如果没有 -1
                                let categoryId = data.arr.length > 0 ? data.change[0].value : -1;
                                $("input[name='categoryId']").val(categoryId);
                            },
                        });
                    }, 'GET');

                    if (data && flag) {
                        xmSelect.render({
                            el: '#selectCategory',
                            disabled: true
                        })
                    }

                    form.val('supplierInfoForm', data);


                    $('#btnUploadCredentials').click(uploadImg('btnUploadCredentials', 'btnUploadCredentials_path', 'certificatePic'))
                    $('#btnUploadDviceAppendix').click(uploadImg('btnUploadDviceAppendix', 'btnUploadDviceAppendix_path', 'openingPermitPic'))

                    // 表单提交事件
                    form.on('submit(supplierInfoFormSubmit)', function (d) {
                        layer.load(2);
                        admin.req(data ? 'enterprise/purchase/admin/supplierInfo/update' : 'enterprise/purchase/admin/supplierInfo/add', d.field, function (res) {
                            layer.closeAll('loading');
                            if (res.code == 200) {
                                layer.msg(res.msg, {icon: 1});
                                table.reload('supplierInfoTable');
                                layer.closeAll('page');
                            } else {
                                layer.msg(res.msg, {icon: 2});
                            }
                        }, data ? 'PUT' : 'POST');
                        return false;
                    });
                }
            });
        }

        // 显示编辑弹窗
        function showEditModel1(data) {
            admin.open({
                type: 1,
                area: '940px',
                offset: '65px',
                title: data ? (flag ?'详情':'修改') : '添加供应商表',
                content: $('#supplierInfoForm').html(),
                success: function () {
                    if(data&&flag){//详情
                        admin.reqSync('enterprisecab/area/admin/area/getProvince', {}, function (res) {
                            if (200 == res.code) {
                                loadSelectHtml(res.data, "请选择省份", "provinceId", 0);
                            }
                        }, 'GET', true);

                        admin.reqSync('enterprisecab/area/admin/area/getCity?parentId=' + data.provinceId, {}, function (res) {
                            if (200 == res.code) {
                                loadSelectHtml(res.data, "请选择城市", "cityId", 0);
                            }
                        }, 'GET', true);

                        admin.reqSync('enterprisecab/area/admin/area/getArea?parentId=' + data.cityId, {}, function (res) {
                            if (200 == res.code) {
                                loadSelectHtml(res.data, "请选择区/县", "areaId", 0);
                            }
                        }, 'GET', true);
                        form.val('supplierInfoForm', data);
                        $("#btnUploadCredentials_path").html("<img src='"+data.certificatePic+"'/>")
                        $("#btnUploadDviceAppendix_path").html("<img src='"+data.openingPermitPic+"'/>")
                        layer.photos({
                            photos: '.uploadImgStyle'
                            ,anim: 5 //0-6的选择，指定弹出图片动画类型，默认随机（请注意，3.0之前的版本用shift参数）
                        });
                        $('[lay-filter="supplierInfoForm"] input').attr("disabled",'');
                        $('[lay-filter="supplierInfoForm"] select').attr("disabled",'');
                        $('[lay-filter="supplierInfoForm"] input').attr("placeholder",' ');
                        $('#supplierInfoFormSubmit').css("display","none")
                        $('#cancel').css("display","none")
                        $('#btnUploadCredentials').css("display","none")
                        $('#btnUploadDviceAppendix').css("display","none")
                    }

                    form.val('supplierInfoForm', data);
                    // 表单提交事件
                    form.on('submit(supplierInfoFormSubmit)', function (d) {
                        layer.load(2);
                        admin.req(data ? 'enterprise/purchase/admin/supplierInfo/update' : 'enterprise/purchase/admin/supplierInfo/add', d.field, function (res) {
                            layer.closeAll('loading');
                            if (res.code == 200) {
                                layer.msg(res.msg, {icon: 1});
                                table.reload('supplierInfoTable');
                                layer.closeAll('page');
                            } else {
                                layer.msg(res.msg, {icon: 2});
                            }
                        }, data ? 'PUT' : 'POST');
                        return false;
                    });
                }
            });
        }

        // 搜索
        form.on('submit(formSubSearchLog)', function (data) {
            insTb.reload({where: data.field, page: {curr: 1}}, 'data');
        });

        // 重置搜索
        form.on('submit(resets)', function (data) {
            insTb.reload({where: admin.resetSearch(data.field), page: {curr: 1}}, 'data');
        });

        // 删除
        function doDelete(obj) {
            layer.confirm('供应商的其他相关信息也将删除，确定要删除吗？', {
                offset: '65px',
                skin: 'layui-layer-admin'
            }, function (i) {
                layer.close(i);
                layer.load(2);
                admin.req('enterprise/purchase/admin/supplierInfo/' + obj.data.id, {}, function (res) {
                    layer.closeAll('loading');
                    if (res.code == 200) {
                        layer.msg(res.msg, {icon: 1});
                        obj.del();
                    } else {
                        layer.msg(res.msg, {icon: 2});
                    }
                }, 'DELETE');
                // insTb.reload();
            });
        }


        $('#SupplierContactsBtnDel').click(function () {
            var checkRows = table.checkStatus('supplierInfoTable');
            if (checkRows.data.length == 0) {
                layer.msg('请选择要删除的数据', {icon: 2});
            } else {
                var ids='';
                checkRows.data.forEach(item=>{
                    ids+=item.id+','
                })
                layer.confirm('供应商的其他相关信息也将删除，确定要删除吗？', {
                    offset: '65px',
                    skin: 'layui-layer-admin'
                },function(){
                    admin.req('enterprise/purchase/admin/supplierInfoPass/delBatch', {ids:ids}, function (res) {
                        if (res.code == 200) {
                            layer.msg(res.msg, {icon: 1});
                        } else {
                            layer.msg(res.msg, {icon: 2});
                        }
                    }, 'POST');
                    insTb.reload();
                })
                //delBatch(ids)
            }
        });

        function delBatch(ids){
            admin.req('enterprise/purchase/admin/supplierInfoPass/delBatch', {ids:ids}, function (res) {
                if (res.code == 200) {
                    layer.msg(res.msg, {icon: 1});
                } else {
                    layer.msg(res.msg, {icon: 2});
                }
            }, 'POST');
            insTb.reload();
        }

        //联系人
        function showContacts(obj){
            admin.open({
                type: 1,
                area: ['70%','80%'],
                title: '供应商联系人管理',
                content: $('#contactsForm').html(),
                success: function () {
                    var contactsTb = table.render({
                        elem: '#supplierContactsTable',
                        url: config.base + 'enterprise/purchase/admin/supplierContacts/list?corporateId='+obj.data.id,
                        page: true,
                        cellMinWidth: 100,
                        cols: [[
                            {type: 'checkbox'}
                            ,{field: 'number', title: '序号', width: 60, type: 'numbers'}
                            ,{field: 'contactName', align: 'center', title: '姓名'}
                            ,{field: 'phoneNumber', align: 'center', title: '电话'}
                            ,{field: 'job', align: 'center', title: '职务'}
                            ,{field: 'corporateName', align: 'center', title: '供应商公司名称', width: 150}
                            ,{field: 'email', align: 'center', title: '邮箱', width: 180}
                            ,{field: 'creatorName', align: 'center', title: '添加人'}
                            ,{field: 'createTime', align: 'center', title: '创建时间', width: 180}
                            ,{align: 'center', toolbar: '#supplierContactsTableBar', title: '操作', width: 150}
                        ]],
                    });
                    // 工具条点击事件
                    var conFlag=true;
                    table.on('tool(supplierContactsTable)', function (obj) {
                        var data = obj.data;
                        if (obj.event === 'editContacts') { //修改
                            conFlag=true;
                            showEditModelContacts(data);
                        } else if (obj.event === 'delContacts') { // 删除
                            doDeleteContacts(obj);
                        }
                    });

                    // 添加按钮点击事件
                    $('#supplierContactsBtnAdd').click(function () {
                        conFlag=false;
                        showEditModelContacts(obj);
                    });

                    // 显示编辑弹窗
                    function showEditModelContacts(data) {
                        let supplierContactsForm = admin.open({
                            type: 1,
                            area: '760px',
                            offset: '155px',
                            title: conFlag ? '修改供应商联系人' : '添加供应商联系人',
                            content: $('#supplierContactsForm').html(),
                            success: function () {
                                if(conFlag){
                                    //data.provinceIdContacts = data.provinceId;
                                    //data.cityIdContacts = data.cityId;
                                    //data.areaIdContacts = data.areaId;
                                    $("#btnUploadCredentials_pathContacts").html("<img src='"+data.cardPic+"'/>")
                                    $("#btnUploadDviceAppendix_pathContacts").html("<img src='"+data.callingCardPic+"'/>")
                                    layer.photos({
                                        photos: '.uploadImgStyle'
                                        ,anim: 5 //0-6的选择，指定弹出图片动画类型，默认随机（请注意，3.0之前的版本用shift参数）
                                    });
                                    admin.reqSync('enterprise/purchase/admin/supplierInfoPass/list?page=1&limit=99999', {}, function (res) {
                                        layer.closeAll('loading');
                                        if (res.code == 200) {
                                            loadSelectHtml(res.data, data.corporateName, "corporateId",1)
                                        }
                                    }, 'GET');
                                    admin.reqSync('enterprisecab/area/admin/area/getProvince', {}, function (res) {
                                        if (200 == res.code) {
                                            loadSelectHtml(res.data, "请选择省份", "provinceId", 0);
                                        }
                                    }, 'GET', true);

                                    admin.reqSync('enterprisecab/area/admin/area/getCity?parentId=' + data.provinceId, {}, function (res) {
                                        if (200 == res.code) {
                                            loadSelectHtml(res.data, "请选择城市", "cityId", 0);
                                        }
                                    }, 'GET', true);

                                    admin.reqSync('enterprisecab/area/admin/area/getArea?parentId=' + data.cityId, {}, function (res) {
                                        if (200 == res.code) {
                                            loadSelectHtml(res.data, "请选择区/县", "areaId", 0);
                                        }
                                    }, 'GET', true);
                                    form.val('supplierContactsForm', data);

                                }else{
                                    //已通过审核供应商名称
                                       admin.reqSync('enterprise/purchase/admin/supplierInfoPass/list?page=1&limit=99999', {}, function (res) {
                                        layer.closeAll('loading');
                                        if (res.code == 200) {
                                            loadSelectHtml(res.data, "请选择供应商", "corporateId",1)
                                            $("#corporateId").html("<option>"+obj.data.corporateName+"</option>");
                                            $("#corporateId").attr("disabled", '');
                                            form.render('select');
                                        }
                                    }, 'GET');

                                    // 获取省区域信息
                                    admin.req('enterprisecab/area/admin/area/getProvince', {}, function (res) {

                                        if (200 == res.code) {
                                            loadSelectHtml(res.data, "请选择省份", "provinceId", 0);
                                        }
                                    }, 'GET', true);
                                    var selectCity = function (province) {
                                        admin.req('enterprisecab/area/admin/area/getCity?parentId=' + province, {}, function (res) {
                                            layer.closeAll('loading');
                                            if (200 == res.code) {
                                                loadSelectHtml(res.data, "请选择市", "cityId", 0);
                                            }
                                        }, 'GET');
                                    }
                                    var selectArea = function (city) {
                                        admin.req('enterprisecab/area/admin/area/getArea?parentId=' + city, {}, function (res) {
                                            layer.closeAll('loading');
                                            if (200 == res.code) {
                                                loadSelectHtml(res.data, "请选择区/县", "areaId", 0);
                                            }
                                        }, 'GET');
                                    }
                                    form.on('select(provinceId)', function (data) {
                                        $("#cityId").empty();
                                        $('#areaId').empty();

                                        // 获取市区域信息
                                        if (data.value != '') {
                                            selectCity(data.value);
                                        }
                                    });

                                    form.on('select(cityId)', function (data) {
                                        $('#areaId').empty();

                                        // 获取区县区域信息
                                        if (data.value != '') {
                                            selectArea(data.value);
                                        }
                                    });
                                }
                                $('#btnUploadCredentialsContacts').click(uploadImg('btnUploadCredentialsContacts','btnUploadCredentials_pathContacts','cardPic'))
                                $('#btnUploadDviceAppendixContacts').click(uploadImg('btnUploadDviceAppendixContacts','btnUploadDviceAppendix_pathContacts','callingCardPic'))
                                // 表单提交事件
                                form.on('submit(supplierContactsFormSubmit)', function (d) {
                                    layer.load(2);
                                    d.field.corporateId=obj.data.id;
                                    admin.req( conFlag? 'enterprise/purchase/admin/supplierContacts/update' : 'enterprise/purchase/admin/supplierContacts/add', d.field, function (res) {
                                        layer.closeAll('loading');
                                        if (res.code == 200) {
                                            layer.msg(res.msg, {icon: 1});
                                            table.reload('supplierContactsTable');
                                            layer.close(supplierContactsForm);
                                        } else {
                                            layer.msg(res.msg, {icon: 2});
                                        }
                                    }, conFlag ? 'PUT' : 'POST');
                                    return false;
                                });
                            }
                        });
                    }


                    // 删除
                    function doDeleteContacts(obj) {
                        layer.confirm('确定要删除吗？', {
                            offset: '65px',
                            skin: 'layui-layer-admin'
                        }, function (i) {
                            layer.close(i);
                            layer.load(2);
                            admin.req('enterprise/purchase/admin/supplierContacts/' + obj.data.id, {}, function (res) {
                                layer.closeAll('loading');
                                if (res.code == 200) {
                                    layer.msg(res.msg, {icon: 1});
                                    obj.del();
                                    table.reload('supplierContactsTable');
                                } else {
                                    layer.msg(res.msg, {icon: 2});
                                }
                            }, 'DELETE');
                            contactsTb.reload();
                        });
                    }


                    $('#SupplierContactsBtnDelContacts').click(function () {
                        var checkRows = table.checkStatus('supplierContactsTable');
                        if (checkRows.data.length == 0) {
                            layer.msg('请选择要删除的数据', {icon: 2});
                        } else {
                            var ids='';
                            checkRows.data.forEach(item=>{
                                ids+=item.id+','
                            })
                            delBatch(ids)
                        }
                    });

                    function delBatch(ids){
                        admin.req('enterprise/purchase/admin/supplierContacts/delBatch', {ids:ids}, function (res) {
                            if (res.code == 200) {
                                layer.msg(res.msg, {icon: 1});
                                table.reload('supplierContactsTable');
                            } else {
                                layer.msg(res.msg, {icon: 2});
                            }
                        }, 'POST');
                        contactsTb.reload();
                    }


                    // 搜索
                    form.on('submit(formSubSearchLogContacts)', function (data) {
                        contactsTb.reload({where: data.field, page: {curr: 1}}, 'data');
                    });

                    // 重置搜索
                    form.on('submit(resetsContacts)', function (data) {
                        $(".lay-header").find('select').val("");
                        $(".lay-header").find('input').val("");
                        var field = data.field;
                        for(let key in field){
                            field[key] = ''
                        }
                        contactsTb.reload({where: field,page: {curr: 1}},'data');
                    });


                }
            })
        }

        // option渲染
        function loadSelectHtml(data, tips, htmltarget, type) {
            let html = ' <option value>' + tips + '</option>';
            if (!data || data == null) {
                return;
            }
            for (let i = 0; i < data.length; i++) {
                if (type === 0) {
                    html += `<option value='${data[i].id}'>${data[i].name}</option>`;
                } else if(type===1){
                    html += `<option value='${data[i].id}'>${data[i].corporateName}</option>`;
                }
            }

            $("form select[name='" + htmltarget + "']").html(html);
            form.render('select');
        }

        // 上传
        function uploadImg(_elem, pathId, inputId,inputName) {
            upload.render({
                elem: '#' + _elem
                , url: config.upload_url + 'uploadFile'
                , data: {}
                , accept: 'file'
                , exts: 'jpg|png|RAR|zip|pdf|txt|doc|docx|xls|xlsx|ppt|pptx'
                , headers: { Authorization: 'Bearer ' + config.getToken() }
                , done: function (res) {
                    if (res.code == 200) {
                        layer.msg(res.msg || "上传成功", { icon: 1 });
                        let imagUrl = res.data.url;
                        $('#' + pathId).html('<img src="' +imagUrl + '"/>');
                        $('#' + inputId).val(imagUrl);
                        if (inputName){
                            $('#' + pathId).html('<span>'+ imagUrl.split('/')[imagUrl.split('/').length-1] +'</span>');
                            $('#' + inputName).val(imagUrl.split('/')[imagUrl.split('/').length-1]);
                        }
                    } else if (res.code == 502) {
                        return location.replace('admin/login.html');
                    } else {
                        layer.msg(res.msg || "上传失败", { icon: 2 });
                    }
                }
            });
        }


        var dueFlag = true;
        //尽调
        function doDue(obj){
            admin.open({
                type: 1,
                area: ['85%','85%'],
                offset: '65px',
                title: '供应商尽调信息',
                content: $('#agentDueForm').html(),
                success: function () {
                    var contcactsTb = table.render({
                        elem: '#agentDueTable',
                        url: config.base + 'enterprise/purchase/admin/supplierDue/list?purSupId='+obj.data.id,
                        page: true,
                        cellMinWidth: 100,
                        cols: [[
                            {type: 'numbers',title:'序号'}
                            ,{field: 'code', sort: true, title: '尽调编号'}
                            ,{field: 'categoryName', sort: false, title: '尽调类型'}
                            ,{field: 'subjectName', sort: false, title: '尽调科目'}
                            ,{field: 'resultDesc', sort: false, title: '尽调结果'}
                            ,{field: 'statusDesc', sort: false, title: '状态'}
                            ,{field: 'createTime', sort: false, title: '录入时间'}
                            ,{field: 'auditor', sort: true, title: '审核人'}
                            ,{field: 'auditTime', sort: false, title: '审核时间'}
                            ,{align: 'center', toolbar: '#agentDueTableBar', title: '操作', width: 200}
                        ]],
                    });
                    /*// 尽调添加按钮点击事件
                    $('#agentDueBtnAdd').click(function () {
                        dueFlag=false;
                        showDueEditModel(obj);
                    });*/
                }
            })
        }

        // 合同
        function showPact(data) {
            var subjectId =data.id;
            admin.open({
                type: 1,
                area: ['80%', '80%'],
                offset: '65px',
                title: '合同',
                content: $('#contract').html(),
                success: function () {

                    // 获取请选择合同分类
                    admin.req('enterprise/contract/admin/contractCategory/getTreeData', {type: "supplier"}, function(res) {
                        if (200 == res.code) {
                            xmSelect.render({
                                el: '#selContractCategory',
                                model: {label: {type: 'text'}},
                                radio: true,
                                clickClose: true,
                                filterable: true,
                                tree: {
                                    show: true,
                                    strict: false,
                                    /*expandedKeys: [-1],*/
                                    expandedKeys: true,
                                },
                                tips: '请选择合同分类',
                                height: 'auto',
                                data() {
                                    return res.data;
                                },
                                on: function (data) {
                                    //被选中的select的id,如果没有 -1
                                    let contractCategoryId = data.arr.length > 0 ? data.change[0].value : "";
                                    $("input[name='contractCategoryId']").val(contractCategoryId);
                                },
                            });
                        } else {
                            layer.msg('获取请选择合同分类失败!', {icon : 2, time : 1000});
                        }
                    }, 'GET');

                    //时间范围
                    laydate.render({
                        elem: '#pTime',
                        type: 'datetime',
                        range: true,
                        done: function (value, date, endDate) {
                            var dateValue = value.split(" - ");
                            $("#sTime").val(dateValue[0]);
                            $("#eTime").val(dateValue[1]);
                        }
                    });

                    // 渲染表格
                    var insTb = table.render({
                        elem: '#contractTable',
                        url: config.base + 'enterprise/purchase/admin/supplierContract/list',
                        where: {subjectId: subjectId},
                        page: true,
                        cellMinWidth: 100,
                        cols: [[
                            {type: 'numbers'}
                            ,{field: 'code', title: '合同编号', width: 130}
                            ,{field: 'typeDesc', title: '合同主体类型', width: 140}
                            ,{field: '', title: '关联订单数', width: 120}
                            ,{field: 'companyName', title: '供应商名称', width: 120}
                            ,{field: 'contractCategoryName', title: '合同分类', width: 120}
                            ,{field: 'createTime', title: '创建时间', width: 170}
                            ,{field: 'contactName', title: '供应商签约人', width: 120}
                            ,{field: 'amount', title: '签约金额', width: 110}
                            ,{field: 'attachment', title: '合同附件', width: 110, toolbar: '#viewAttachmentBar'}
                            ,{field: 'statusDesc', title: '合同状态', width: 110}
                            ,{align: 'center', toolbar: '#contractTableBar', title: '操作', width: 300}
                        ]],
                        done: function (res, curr, count) {
                            //移除按钮
                            var menuButton = config.getMenuButton(location.hash);
                            if(menuButton.indexOf("搜索") == -1){
                                $('.layui-form.toolbar').remove();
                            }
                            if(menuButton.indexOf("修改") == -1){
                                $("[lay-event='edit']").remove();
                            }
                            if(menuButton.indexOf("删除") == -1){
                                $("[lay-event='del']").remove();
                            }
                        }
                    });

                    // 工具条点击事件
                    table.on('tool(contractTable)', function (obj) {
                        var data = obj.data;
                        if (obj.event === 'edit') { //修改
                            showEditModel(data);
                        } else if (obj.event === 'del') { // 删除
                            doDelete(obj);
                        } else if (obj.event === 'view') { // 详情
                            showViewModel(data);
                        } else if (obj.event === 'changeRecord') { // 变更记录
                            showChangeRecordModel(data);
                        } else if (obj.event === 'relatedProduct') { // 物料
                            showRelatedProductModel(data);
                        } else if (obj.event === 'viewAttachment') { // 查看附件
                            showViewAttachmentModel(data);
                        }
                    });

                    // 搜索
                    form.on('submit(formSubSearchLog)', function (data) {
                        insTb.reload({where: data.field,page: {curr: 1}},'data');
                    });

                    // 重置搜索
                    form.on('submit(resets)', function (data) {
                        $(".lay-header").find('select').val("");
                        $(".lay-header").find('input').val("");
                        let field = data.field;
                        for (let key in field) {
                            field[key] = ''
                        }
                        insTb.reload({where: field, page: {curr: 1}}, 'data');
                    });

                    // 添加按钮点击事件
                    $('#contractBtnAdd').click(function () {
                        showEditModel();
                    });

                    // 显示编辑弹窗
                    function showEditModel(data) {
                        var contractTable = admin.open({
                            type: 1,
                            area: '800px',
                            offset: '65px',
                            title: data ? '修改合同' : '添加合同',
                            content: $('#contractForm').html(),
                            success: function () {
                                //自定义验证规则
                                form.verify({
                                    decimal: [/^[0-9]*(\.[0-9]{1,2})?$/, '格式错误'],
                                    contractCategoryId: function (value) {
                                        if(value == ""){
                                            return "请选择请选择合同分类";
                                        }
                                    },
                                    attachment: function (value) {
                                        if(value == ""){
                                            return "请上传附件";
                                        }
                                    }
                                })

                                // 获取合同主体类型
                                admin.req('enterprise/contract/admin/contractCategory/types', {}, function(res) {
                                    if (200 == res.code) {
                                        $.each(res.data, function(index, item) {
                                            $("form select[name='type']").append(new Option(item.name, item.id));//往下拉菜单里添加元素
                                        })
                                        $("form select[name='type']").find("option").each(function (index, item) {
                                            // 默认主体类型为供应商
                                            if($(item).val() == "supplier"){
                                                $(item).attr("selected", true);
                                            }
                                        })
                                        form.render(); //菜单渲染 把内容加载进去
                                    } else {
                                        layer.msg('获取合同主体类型失败!', {icon : 2, time : 1000});
                                    }
                                }, 'GET');

                                var selectId = null;
                                if(data && data.contractCategoryId){
                                    selectId = data.contractCategoryId;
                                }
                                // 获取请选择合同分类
                                admin.req('enterprise/contract/admin/contractCategory/getTreeData', {selectId: selectId, type: "supplier"}, function(res) {
                                    if (200 == res.code) {
                                        xmSelect.render({
                                            el: '#selectContractCategory',
                                            model: {label: {type: 'text'}},
                                            radio: true,
                                            clickClose: true,
                                            filterable: true,
                                            tree: {
                                                show: true,
                                                strict: false,
                                                /*expandedKeys: [-1],*/
                                                expandedKeys: true,
                                            },
                                            tips: '请选择合同分类',
                                            height: 'auto',
                                            data() {
                                                return res.data;
                                            },
                                            on: function (data) {
                                                //被选中的select的id,如果没有 -1
                                                let contractCategoryId = data.arr.length > 0 ? data.change[0].value : "";
                                                $("form input[name='contractCategoryId']").val(contractCategoryId);
                                            },
                                        });
                                    } else {
                                        layer.msg('获取请选择合同分类失败!', {icon : 2, time : 1000});
                                    }
                                }, 'GET');

                                // 获取签约主体
                                admin.req('enterprise/purchase/admin/supplierInfoPass/list', {limit: 99999}, function(res) {
                                    console.log(res.data);
                                    if (200 == res.code) {

                                        $("form select[name='subjectId']").append(new Option("请选择签约主体", ""));//往下拉菜单里添加元素
                                        $.each(res.data, function(index, item) {
                                            $("form select[name='subjectId']").append(new Option(item.corporateName, item.id));//往下拉菜单里添加元素
                                        })
                                        $("form select[name='subjectId']").val(subjectId);
                                        form.render(); //菜单渲染 把内容加载进去
                                    } else {
                                        layer.msg('获取签约主体失败!', {icon : 2, time : 1000});
                                    }
                                }, 'GET');

                                // 获取供应商签约人
                                admin.req('enterprise/purchase/admin/supplierContacts/list', {limit: 99999, corporateId: subjectId}, function(res) {
                                    if (200 == res.code) {
                                        $("form select[name='contactsId']").html("");
                                        $("form select[name='contactsId']").append(new Option("请选择供应商签约人", ""));//往下拉菜单里添加元素
                                        $.each(res.data, function(index, item) {
                                            $("form select[name='contactsId']").append(new Option(item.contactName+"("+item.phoneNumber+")", item.id));//往下拉菜单里添加元素
                                        })
                                        form.render(); //菜单渲染 把内容加载进去
                                        if(data && data.contactsId){
                                            form.val('contractForm', data);
                                        }
                                    } else {
                                        layer.msg('获取供应商签约人失败!', {icon : 2, time : 1000});
                                    }
                                }, 'GET');

                                // 获取我方签约人
                                admin.req('user/admin/user/list', {limit: 99999}, function(res) {
                                    console.log(res.data);
                                    if (200 == res.code) {
                                        $("form select[name='contractor']").append(new Option("请选择我方签约人", ""));//往下拉菜单里添加元素
                                        $.each(res.data, function(index, item) {
                                            $("form select[name='contractor']").append(new Option(item.nickname+"("+item.username+")", item.id));//往下拉菜单里添加元素
                                        })
                                        form.render(); //菜单渲染 把内容加载进去
                                        if(data && data.contractor){
                                            form.val('contractForm', data);
                                        }
                                    } else {
                                        layer.msg('获取我方签约人失败!', {icon : 2, time : 1000});
                                    }
                                }, 'GET');

                                // 获取信息审批人
                                admin.req('user/admin/user/list', {limit: 99999}, function(res) {
                                    console.log(res.data);
                                    if (200 == res.code) {
                                        $("form select[name='approver']").append(new Option("请选择信息审批人", ""));//往下拉菜单里添加元素
                                        $.each(res.data, function(index, item) {
                                            $("form select[name='approver']").append(new Option(item.nickname+"("+item.username+")", item.id));//往下拉菜单里添加元素
                                        })
                                        form.render(); //菜单渲染 把内容加载进去
                                        if(data && data.approver){
                                            form.val('contractForm', data);
                                        }
                                    } else {
                                        layer.msg('获取信息审批人失败!', {icon : 2, time : 1000});
                                    }
                                }, 'GET');

                                // 上传附件
                                upload.render({
                                    elem: '#addDevicePicBtn'
                                    , url: config.upload_url + 'uploadFile'
                                    , data: {}
                                    , accept: 'file'
                                    , exts: 'pdf'
                                    , headers: {Authorization: 'Bearer ' + config.getToken()}
                                    , done: function (res) {
                                        if (res.code == 200) {
                                            layer.msg(res.msg || "上传成功", {icon: 1});
                                            let imagUrl = res.data.url;
                                            var name = res.data.fileName;
                                            $('#addHeaderImg').html('<div class="attachments">' +
                                                '<div><img src="../../../admin/assets/images/attachmentsIcon/pdf.png"><span class="file-a">'+name+'</span></div></div>');
                                            $('#attachment').val(imagUrl);

                                            $(".attachments").click(function () {
                                                var json = {};
                                                json.attachment = imagUrl;
                                                showViewAttachmentModel(json);
                                            })
                                        } else if (res.code == 502) {
                                            return location.replace('admin/login.html');
                                        } else {
                                            layer.msg(res.msg || "上传失败", {icon: 2});
                                        }
                                    }
                                });

                                form.val('contractForm', data);
                                // 表单提交事件
                                form.on('submit(contractFormSubmit)', function (d) {
                                    layer.load(2);
                                    admin.req(data ? 'enterprise/purchase/admin/supplierContract/update' : 'enterprise/purchase/admin/supplierContract/add', d.field, function (res) {
                                        layer.closeAll('loading');
                                        if (res.code == 200) {
                                            layer.msg(res.msg, {icon: 1});
                                            table.reload('contractTable');
                                            layer.close(contractTable);
                                        } else {
                                            layer.msg(res.msg, {icon: 2});
                                        }
                                    }, data ? 'PUT' : 'POST');
                                    return false;
                                });
                            }
                        });
                    }

                    // 删除
                    function doDelete(obj) {
                        layer.confirm('确定要删除吗？', {
                            offset: '65px',
                            skin: 'layui-layer-admin'
                        }, function (i) {
                            layer.close(i);
                            layer.load(2);
                            admin.req('enterprise/purchase/admin/supplierContract/' + obj.data.id, {}, function (res) {
                                layer.closeAll('loading');
                                if (res.code == 200) {
                                    layer.msg(res.msg, {icon: 1});
                                    obj.del();
                                } else {
                                    layer.msg(res.msg, {icon: 2});
                                }
                            }, 'DELETE');
                        });
                    }

                    // 显示详情弹窗
                    function showViewModel(data) {
                        admin.open({
                            type: 1,
                            area: ['80%', '80%'],
                            offset: '65px',
                            title: '合同详情',
                            content: $('#contractView').html(),
                            success: function () {
                                // 查询我方签约人
                                admin.req('user/admin/user/list', {limit: 99999}, function(res) {
                                    console.log(res.data);
                                    if (200 == res.code) {
                                        $.each(res.data, function(index, item) {
                                            if(item.id == data.contractor){
                                                $("#contractorName").text("我方签约人："+item.nickname+"("+item.username+")");
                                            }
                                        })
                                    } else {
                                        layer.msg('获取我方签约人失败!', {icon : 2, time : 1000});
                                    }
                                }, 'GET');

                                // 查询合同保管员
                                admin.req('user/admin/user/list', {limit: 99999}, function(res) {
                                    if (200 == res.code) {
                                        $.each(res.data, function(index, item) {
                                            if(item.id == data.keeper){
                                                $("#keeperName").text("合同保管员："+item.nickname+"("+item.username+")");
                                            }
                                        })
                                    } else {
                                        layer.msg('获取合同保管员失败!', {icon : 2, time : 1000});
                                    }
                                }, 'GET');

                                // 查询信息审批人
                                admin.req('user/admin/user/list', {limit: 99999}, function(res) {
                                    if (200 == res.code) {
                                        $.each(res.data, function(index, item) {
                                            if(item.id == data.approver){
                                                $("#approverName").text("信息审批人："+item.nickname+"("+item.username+")");
                                            }
                                        })
                                    } else {
                                        layer.msg('获取信息审批人失败!', {icon : 2, time : 1000});
                                    }
                                }, 'GET');

                                $("#attachmentName").text("合同附件："+data.attachment.substring(data.attachment.lastIndexOf("/")+1));

                                laytpl(contractInfoHtml.innerHTML).render(data, function (html) {
                                    $("#contractInfo").html(html);
                                });

                                if(data.attachment){
                                    PDFObject.embed(data.attachment, "#example1");
                                }
                            }
                        })
                    }

                    // 变更记录
                    function showChangeRecordModel(data) {
                        var supplierContract = data;
                        admin.open({
                            type: 1,
                            area: ['80%', '80%'],
                            offset: '65px',
                            title: '合同变更记录',
                            content: $('#contractChangeRecord').html(),
                            success: function () {
                                isShowAddBtn(supplierContract);

                                // 渲染表格
                                var changeRecordInsTb = table.render({
                                    elem: '#contractChangeRecordTable',
                                    url: config.base + 'enterprise/purchase/admin/supplierContract/contractChangeRecordList',
                                    where: {contractId: supplierContract.id},
                                    page: true,
                                    cellMinWidth: 100,
                                    cols: [[
                                        {type: 'numbers'}
                                        ,{field: 'code', title: '合同编号', width: 130}
                                        ,{field: 'typeDesc', title: '合同主体类型', width: 140}
                                        ,{field: 'companyName', title: '供应商名称', width: 120}
                                        ,{field: 'contractCategoryName', title: '合同分类', width: 120}
                                        ,{field: 'createTime', title: '创建时间', width: 170}
                                        ,{field: 'contactName', title: '供应商签约人', width: 120}
                                        ,{field: 'amount', title: '签约金额', width: 110}
                                        ,{field: 'attachment', title: '合同附件', width: 110, toolbar: '#viewAttachmentBar'}
                                        ,{field: 'statusDesc', title: '合同状态', width: 110}
                                        ,{align: 'center', toolbar: '#contractChangeRecordTableBar', title: '操作', width: 200}
                                    ]],
                                    done: function (res, curr, count) {

                                    }
                                });

                                // 工具条点击事件
                                table.on('tool(contractChangeRecordTable)', function (obj) {
                                    var data = obj.data;
                                    if (obj.event === 'edit') { // 修改
                                        showEditModel(data);
                                    } else if (obj.event === 'view') { // 详情
                                        showViewModel(data);
                                    } else if (obj.event === 'audit') { // 审核
                                        showAuditModel(data);
                                    } else if (obj.event === 'final') { // 终版
                                        doFinal(data);
                                    } else if (obj.event === 'viewAttachment') { // 查看附件
                                        showViewAttachmentModel(data);
                                    }
                                });

                                // 搜索
                                form.on('submit(contractChangeRecordFormSubSearchLog)', function (data) {
                                    changeRecordInsTb.reload({where: data.field,page: {curr: 1}},'data');
                                });

                                // 重置搜索
                                form.on('submit(contractChangeRecordResets)', function (data) {
                                    $("#changeRecord").find(".lay-header").find('select').val("");
                                    $("#changeRecord").find(".lay-header").find('input').val("");
                                    let field = data.field;
                                    for (let key in field) {
                                        field[key] = ''
                                    }
                                    changeRecordInsTb.reload({where: field, page: {curr: 1}}, 'data');
                                });

                                // 添加按钮点击事件
                                $('#contractChangeRecordBtnAdd').click(function () {
                                    showEditModel();
                                });

                                // 显示编辑弹窗
                                function showEditModel(data) {
                                    var contractChangeRecord = admin.open({
                                        type: 1,
                                        area: ['800px', '80%'],
                                        offset: '65px',
                                        title: data ? '修改合同变更记录' : '添加合同变更记录',
                                        content: $('#contractChangeRecordForm').html(),
                                        success: function () {
                                            //自定义验证规则
                                            form.verify({
                                                decimal: [/^[0-9]*(\.[0-9]{1,2})?$/, '格式错误'],
                                                contractCategoryId: function (value) {
                                                    if(value == ""){
                                                        return "请选择请选择合同分类";
                                                    }
                                                },
                                                attachment: function (value) {
                                                    if(value == ""){
                                                        return "请上传附件";
                                                    }
                                                }
                                            })

                                            // 签约时间
                                            laydate.render({
                                                elem: '#signingTime',
                                                type: 'date'
                                            });

                                            // 交货时间
                                            laydate.render({
                                                elem: '#deliveryTime',
                                                type: 'date'
                                            });

                                            var selectId = null;
                                            if(supplierContract && supplierContract.contractCategoryId){
                                                selectId = supplierContract.contractCategoryId;
                                            }
                                            if(data && data.contractCategoryId){
                                                selectId = data.contractCategoryId;
                                            }
                                            // 获取请选择合同分类
                                            admin.req('enterprise/contract/admin/contractCategory/getTreeData', {selectId: selectId, type: "supplier"}, function(res) {
                                                if (200 == res.code) {
                                                    xmSelect.render({
                                                        el: '#selectContractCategory',
                                                        model: {label: {type: 'text'}},
                                                        radio: true,
                                                        clickClose: true,
                                                        filterable: true,
                                                        tree: {
                                                            show: true,
                                                            strict: false,
                                                            /*expandedKeys: [-1],*/
                                                            expandedKeys: true,
                                                        },
                                                        tips: '请选择合同分类',
                                                        height: 'auto',
                                                        data() {
                                                            return res.data;
                                                        },
                                                        on: function (data) {
                                                            //被选中的select的id,如果没有 -1
                                                            let contractCategoryId = data.arr.length > 0 ? data.change[0].value : "";
                                                            $("input[name='contractCategoryId']").val(contractCategoryId);
                                                        },
                                                    });
                                                } else {
                                                    layer.msg('获取请选择合同分类失败!', {icon : 2, time : 1000});
                                                }
                                            }, 'GET');

                                            var corporateId = null;
                                            if(supplierContract && supplierContract.subjectId){
                                                corporateId = supplierContract.subjectId;
                                            }
                                            if(data && data.subjectId){
                                                corporateId = data.subjectId;
                                            }
                                            if(corporateId){
                                                // 获取供应商签约人
                                                admin.req('enterprise/purchase/admin/supplierContacts/list', {limit: 99999, corporateId: corporateId}, function(res) {
                                                    if (200 == res.code) {
                                                        $("form select[name='contactsId']").html("");
                                                        $("form select[name='contactsId']").append(new Option("请选择供应商签约人", ""));//往下拉菜单里添加元素
                                                        $.each(res.data, function(index, item) {
                                                            $("form select[name='contactsId']").append(new Option(item.contactName+"("+item.phoneNumber+")", item.id));//往下拉菜单里添加元素
                                                        })
                                                        form.render(); //菜单渲染 把内容加载进去
                                                        if(data && data.contactsId){
                                                            form.val('contractChangeRecordForm', data);
                                                        }else{
                                                            form.val('contractChangeRecordForm', supplierContract);
                                                        }
                                                    } else {
                                                        layer.msg('获取供应商签约人失败!', {icon : 2, time : 1000});
                                                    }
                                                }, 'GET');
                                            }


                                            // 获取我方签约人
                                            admin.req('user/admin/user/list', {limit: 99999}, function(res) {
                                                if (200 == res.code) {
                                                    $("form select[name='contractor']").append(new Option("请选择我方签约人", ""));//往下拉菜单里添加元素
                                                    $.each(res.data, function(index, item) {
                                                        $("form select[name='contractor']").append(new Option(item.nickname+"("+item.username+")", item.id));//往下拉菜单里添加元素
                                                    })
                                                    form.render(); //菜单渲染 把内容加载进去
                                                    if(data && data.contractor){
                                                        form.val('contractChangeRecordForm', data);
                                                    }else{
                                                        form.val('contractChangeRecordForm', supplierContract);
                                                    }
                                                } else {
                                                    layer.msg('获取我方签约人失败!', {icon : 2, time : 1000});
                                                }
                                            }, 'GET');

                                            // 获取信息审批人
                                            admin.req('user/admin/user/list', {limit: 99999}, function(res) {
                                                if (200 == res.code) {
                                                    $("form select[name='approver']").append(new Option("请选择信息审批人", ""));//往下拉菜单里添加元素
                                                    $.each(res.data, function(index, item) {
                                                        $("form select[name='approver']").append(new Option(item.nickname+"("+item.username+")", item.id));//往下拉菜单里添加元素
                                                    })
                                                    form.render(); //菜单渲染 把内容加载进去
                                                    if(data && data.approver){
                                                        form.val('contractChangeRecordForm', data);
                                                    }else{
                                                        form.val('contractChangeRecordForm', supplierContract);
                                                    }
                                                } else {
                                                    layer.msg('获取信息审批人失败!', {icon : 2, time : 1000});
                                                }
                                            }, 'GET');

                                            // 上传附件
                                            upload.render({
                                                elem: '#addDevicePicBtn'
                                                , url: config.upload_url + 'uploadFile'
                                                , data: {}
                                                , accept: 'file'
                                                , exts: 'pdf'
                                                , headers: {Authorization: 'Bearer ' + config.getToken()}
                                                , done: function (res) {
                                                    if (res.code == 200) {
                                                        layer.msg(res.msg || "上传成功", {icon: 1});
                                                        let imagUrl = res.data.url;
                                                        var name = res.data.fileName;
                                                        $('#addHeaderImg').html('<div class="attachments">' +
                                                            '<div><img src="../../../admin/assets/images/attachmentsIcon/pdf.png"><span class="file-a">'+name+'</span></div></div>');
                                                        $('#attachment').val(imagUrl);

                                                        $(".attachments").click(function () {
                                                            var json = {};
                                                            json.attachment = imagUrl;
                                                            showViewAttachmentModel(json);
                                                        })
                                                    } else if (res.code == 502) {
                                                        return location.replace('admin/login.html');
                                                    } else {
                                                        layer.msg(res.msg || "上传失败", {icon: 2});
                                                    }
                                                }
                                            });

                                            var attachment = "";
                                            if(supplierContract && supplierContract.attachment){
                                                attachment = supplierContract.attachment;
                                            }
                                            if(data && data.attachment){
                                                attachment = data.attachment;
                                            }

                                            if(attachment != ""){
                                                var name = attachment.substring(attachment.lastIndexOf("/")+1);
                                                // onclick="previewFile(\''+name+'\', \''+attachment+'\')"
                                                $('#addHeaderImg').html('<div class="attachments">' +
                                                    '<div><img src="../../../admin/assets/images/attachmentsIcon/pdf.png"><span class="file-a">'+name+'</span></div></div>');
                                                $('#attachment').val(attachment);

                                                $(".attachments").click(function () {
                                                    var json = {};
                                                    json.attachment = attachment;
                                                    showViewAttachmentModel(json);
                                                })
                                            }

                                            // 获取合同保管员
                                            admin.req('user/admin/user/list', {limit: 99999}, function(res) {
                                                if (200 == res.code) {
                                                    $("form select[name='keeper']").append(new Option("请选择合同保管员", ""));//往下拉菜单里添加元素
                                                    $.each(res.data, function(index, item) {
                                                        $("form select[name='keeper']").append(new Option(item.nickname+"("+item.username+")", item.id));//往下拉菜单里添加元素
                                                    })
                                                    form.render(); //菜单渲染 把内容加载进去
                                                    if(data && data.keeper){
                                                        form.val('contractChangeRecordForm', data);
                                                    }
                                                } else {
                                                    layer.msg('获取合同保管员失败!', {icon : 2, time : 1000});
                                                }
                                            }, 'GET');

                                            form.on('switch(isFinal)',function(obj){
                                                if(obj.elem.checked){
                                                    $("#content").show();
                                                    $("#deliveryTime").attr("lay-verify", "required").attr("required");
                                                    $("input[name='address']").attr("lay-verify", "required").attr("required", true);
                                                    $("select[name='keeper']").attr("lay-verify", "required").attr("required", true).attr("lay-search", true);
                                                    form.render();
                                                }else{
                                                    $("#content").hide();
                                                    $("#deliveryTime").removeAttr("lay-verify");
                                                    $("input[name='address']").removeAttr("lay-verify");
                                                    $("select[name='keeper']").removeAttr("lay-verify");
                                                }
                                            })

                                            if(data){
                                                form.val('contractChangeRecordForm', data);
                                            }else{
                                                form.val('contractChangeRecordForm', supplierContract);
                                            }
                                            // 表单提交事件
                                            form.on('submit(contractChangeRecordFormSubmit)', function (d) {
                                                layer.load(2);
                                                var isFinal=$("form input[name='isFinal']").prop("checked");
                                                if(!isFinal){
                                                    d.field.isFinal=false;
                                                }else{
                                                    d.field.isFinal=true;
                                                }
                                                if(d.field.signingTime){
                                                    d.field.signingTime = d.field.signingTime + " 00:00:00";
                                                }
                                                if(d.field.deliveryTime){
                                                    d.field.deliveryTime = d.field.deliveryTime + " 00:00:00";
                                                }
                                                d.field.contractId = supplierContract.id;
                                                admin.req(data ? 'enterprise/purchase/admin/supplierContract/updateContractChangeRecord' : 'enterprise/purchase/admin/supplierContract/addContractChangeRecord', d.field, function (res) {
                                                    layer.closeAll('loading');
                                                    if (res.code == 200) {
                                                        layer.msg(res.msg, {icon: 1});
                                                        isShowAddBtn(supplierContract);
                                                        table.reload('contractChangeRecordTable');
                                                        layer.close(contractChangeRecord);
                                                    } else {
                                                        layer.msg(res.msg, {icon: 2});
                                                    }
                                                }, data ? 'PUT' : 'POST');
                                                return false;
                                            });
                                        }
                                    });
                                }

                                // 显示审核弹窗
                                function showAuditModel(data) {
                                    var contractAudit = admin.open({
                                        type: 1,
                                        area: ['80%', '80%'],
                                        offset: '65px',
                                        title: '合同审核',
                                        content: $('#contractAuditForm').html(),
                                        success: function () {
                                            // 查询我方签约人
                                            admin.req('user/admin/user/list', {limit: 99999}, function(res) {
                                                if (200 == res.code) {
                                                    $.each(res.data, function(index, item) {
                                                        if(item.id == data.contractor){
                                                            $("#contractorName").text("我方签约人："+item.nickname+"("+item.username+")");
                                                        }
                                                    })
                                                } else {
                                                    layer.msg('获取我方签约人失败!', {icon : 2, time : 1000});
                                                }
                                            }, 'GET');

                                            // 查询合同保管员
                                            admin.req('user/admin/user/list', {limit: 99999}, function(res) {
                                                if (200 == res.code) {
                                                    $.each(res.data, function(index, item) {
                                                        if(item.id == data.keeper){
                                                            $("#keeperName").text("合同保管员："+item.nickname+"("+item.username+")");
                                                        }
                                                    })
                                                } else {
                                                    layer.msg('获取合同保管员失败!', {icon : 2, time : 1000});
                                                }
                                            }, 'GET');

                                            // 查询信息审批人
                                            admin.req('user/admin/user/list', {limit: 99999}, function(res) {
                                                if (200 == res.code) {
                                                    $.each(res.data, function(index, item) {
                                                        if(item.id == data.approver){
                                                            $("#approverName").text("信息审批人："+item.nickname+"("+item.username+")");
                                                        }
                                                    })
                                                } else {
                                                    layer.msg('获取信息审批人失败!', {icon : 2, time : 1000});
                                                }
                                            }, 'GET');


                                            $("#attachmentName").text("合同附件："+data.attachment.substring(data.attachment.lastIndexOf("/")+1));

                                            laytpl(contractInfoHtml.innerHTML).render(data, function (html) {
                                                $("#contractInfo").html(html);
                                            });

                                            if(data.attachment){
                                                PDFObject.embed(data.attachment, "#example1");
                                            }

                                            form.val('contractAuditForm', data);

                                            // 表单提交事件
                                            form.on('submit(contractAuditFormSubmit)', function (d) {
                                                layer.load(2);
                                                d.field.status = $(this).data("status");
                                                admin.req('enterprise/purchase/admin/supplierContract/auditContractChangeRecord', d.field, function (res) {
                                                    layer.closeAll('loading');
                                                    if (res.code == 200) {
                                                        layer.msg(res.msg, {icon: 1});
                                                        isShowAddBtn(supplierContract);
                                                        table.reload('contractChangeRecordTable');
                                                        layer.close(contractAudit);
                                                    } else {
                                                        layer.msg(res.msg, {icon: 2});
                                                    }
                                                }, 'POST');
                                                return false;
                                            });

                                        }
                                    })
                                }

                                // 终版
                                function doFinal(data) {
                                    var contractFinal = admin.open({
                                        type: 1,
                                        area: ['800px'],
                                        offset: '65px',
                                        title: '合同终版确认',
                                        content: $('#contractFinalForm').html(),
                                        success: function () {
                                            // 交货时间
                                            laydate.render({
                                                elem: '#deliveryTime',
                                                type: 'date'
                                            });

                                            // 获取合同保管员
                                            admin.req('user/admin/user/list', {limit: 99999}, function(res) {
                                                if (200 == res.code) {
                                                    $("form select[name='keeper']").append(new Option("请选择合同保管员", ""));//往下拉菜单里添加元素
                                                    $.each(res.data, function(index, item) {
                                                        $("form select[name='keeper']").append(new Option(item.nickname+"("+item.username+")", item.id));//往下拉菜单里添加元素
                                                    })
                                                    form.render(); //菜单渲染 把内容加载进去
                                                } else {
                                                    layer.msg('获取合同保管员失败!', {icon : 2, time : 1000});
                                                }
                                            }, 'GET');

                                            form.val('contractFinalForm', data);

                                            // 表单提交事件
                                            form.on('submit(contractFinalFormSubmit)', function (d) {
                                                layer.load(2);
                                                if(d.field.deliveryTime){
                                                    d.field.deliveryTime = d.field.deliveryTime + " 00:00:00";
                                                }
                                                admin.req('enterprise/purchase/admin/supplierContract/setContractFinal', d.field, function (res) {
                                                    layer.closeAll('loading');
                                                    if (res.code == 200) {
                                                        layer.msg(res.msg, {icon: 1});
                                                        isShowAddBtn(supplierContract);
                                                        table.reload('contractChangeRecordTable');
                                                        table.reload('contractTable');
                                                        layer.close(contractFinal);
                                                    } else {
                                                        layer.msg(res.msg, {icon: 2});
                                                    }
                                                }, 'POST');
                                                return false;
                                            });

                                        }
                                    })

                                }

                            }
                        })
                    }

                    // 关联物料
                    function showRelatedProductModel(data) {
                        var contractData = data;
                        admin.open({
                            type: 1,
                            area: ['80%', '80%'],
                            offset: '65px',
                            title: '合同关联物料',
                            content: $('#contractRelatedProduct').html(),
                            success: function () {

                                // 渲染表格
                                table.render({
                                    elem: '#contractRelatedProductContractTable',
                                    data: [contractData],
                                    page: false,
                                    cellMinWidth: 100,
                                    cols: [[
                                        {type: 'numbers'}
                                        ,{field: 'code', title: '合同编号', width: 130}
                                        ,{field: 'typeDesc', title: '合同主体类型', width: 140}
                                        ,{field: 'companyName', title: '供应商名称', width: 120}
                                        ,{field: 'contractCategoryName', title: '合同分类', width: 120}
                                        ,{field: 'createTime', title: '创建时间', width: 170}
                                        ,{field: 'contactName', title: '供应商签约人', width: 120}
                                        ,{field: 'amount', title: '签约金额', width: 110}
                                        ,{field: 'attachment', title: '合同附件', width: 110, toolbar: '#viewAttachmentBar'}
                                        ,{field: 'statusDesc', title: '合同状态', width: 110}
                                        ,{field: '', title: '操作', width: 120, toolbar: '#customerPhoneBar'}
                                    ]],
                                    done: function (res, curr, count) {

                                    }
                                });

                                // 渲染表格
                                table.render({
                                    elem: '#contractRelatedProductTable',
                                    // url: config.base + 'enterprise/purchase/admin/supplierContract/contractRelatedProductList',
                                    // where: {contractId: data.id},
                                    data: [],
                                    page: false,
                                    cellMinWidth: 100,
                                    cols: [[
                                        {type: 'numbers'}
                                        ,{field: 'code', title: '供应商物料编码(SKU料号)', width: 130}
                                        ,{field: 'typeDesc', title: '供应商物料名称', width: 140}
                                        ,{field: 'companyName', title: '供应商规格名称', width: 120}
                                        ,{field: 'contractCategoryName', title: '内部物料料号（SKUID）', width: 120}
                                        ,{field: 'createTime', title: '内部物料类型', width: 170}
                                        ,{field: 'contactName', title: '内部规格码', width: 120}
                                        ,{field: 'attachment', title: '合同附件', width: 110, toolbar: '#viewAttachmentBar'}
                                        ,{field: 'amount', title: '描述', width: 110}
                                        ,{field: 'statusDesc', title: '物料状态', width: 110}
                                        ,{align: 'center', toolbar: '#contractChangeRecordTableBar', title: '操作', width: 200}
                                    ]],
                                    done: function (res, curr, count) {

                                    }
                                });

                                // 工具条点击事件
                                table.on('tool(contractRelatedProductContractTable)', function (obj) {
                                    var data = obj.data;
                                    if (obj.event === 'viewAttachment') { // 查看附件
                                        showViewAttachmentModel(data);
                                    } else if (obj.event === 'viewCustomerPhone') { // 查看供应商手机号
                                        viewCustomerPhone(data);
                                    }
                                });

                                // 添加合同物料信息
                                $("#addContractProductInfo").click(function () {
                                    showEditModel();
                                })

                                // 查看供应商手机号
                                function viewCustomerPhone(data) {
                                    layer.open({
                                        title: '供应商手机号',
                                        content: data.contactPhone
                                    });
                                }

                                // 显示编辑弹窗
                                function showEditModel(data) {
                                    var contractRelatedProduct = admin.open({
                                        type: 1,
                                        area: ['70%', '70%'],
                                        offset: '65px',
                                        title: data ? '修改合同物料信息' : '添加合同物料信息',
                                        content: $('#contractRelatedProductForm').html(),
                                        success: function () {
                                            //自定义验证规则
                                            form.verify({
                                                decimal: [/^[0-9]*(\.[0-9]{1,2})?$/, '格式错误'],
                                                attachment: function (value) {
                                                    if(value == ""){
                                                        return "请上传附件";
                                                    }
                                                }
                                            })

                                            // 渲染表格
                                            table.render({
                                                elem: '#contractRelatedProductCustomerTable',
                                                data: [contractData],
                                                page: false,
                                                cellMinWidth: 100,
                                                cols: [[
                                                    {field: 'name', title: '供应商名称', width: 130}
                                                    ,{field: 'code', title: '供应商编码', width: 130}
                                                    ,{field: 'typeDesc', title: '供应商联系人', width: 140}
                                                    ,{field: 'companyName', title: '供应商级别', width: 120}
                                                    ,{field: 'contractCategoryName', title: '录入人', width: 120}
                                                    ,{field: 'createTime', title: '供应商信息录入时间', width: 170}
                                                    ,{field: 'contactName', title: '客服代表', width: 120}
                                                ]],
                                                done: function (res, curr, count) {

                                                }
                                            });

                                            // 渲染表格
                                            table.render({
                                                elem: '#contractRelatedProductContractTable',
                                                data: [contractData],
                                                page: false,
                                                cellMinWidth: 100,
                                                cols: [[
                                                    {field: 'code', title: '合同编号', width: 130}
                                                    ,{field: 'typeDesc', title: '所属请选择合同分类', width: 140}
                                                    ,{field: 'companyName', title: '合同提交时间', width: 120}
                                                    ,{field: 'contractCategoryName', title: '我方签约人', width: 120}
                                                    ,{field: 'createTime', title: '合同审核', width: 170}
                                                    ,{field: 'attachment', title: '合同附件', width: 110, toolbar: '#viewAttachmentBar'}
                                                    ,{field: 'statusDesc', title: '合同状态', width: 110}
                                                    ,{field: 'amount', title: '供应商签约人', width: 110}
                                                ]],
                                                done: function (res, curr, count) {

                                                }
                                            });



                                        }
                                    });
                                }

                            }
                        })
                    }

                    // 查看附件
                    function showViewAttachmentModel(data) {
                        admin.open({
                            type: 1,
                            area: ['60%', '80%'],
                            offset: '65px',
                            title: '查看附件',
                            content: $('#viewAttachmentHtml').html(),
                            success: function () {
                                if(data.attachment){
                                    PDFObject.embed(data.attachment, "#example1");
                                }
                            }
                        })
                    }

                    // 是否显示添加合同变更记录按钮
                    function isShowAddBtn(data){
                        admin.req('enterprise/purchase/admin/supplierContract/isShowAddBtn', {id: data.id}, function(res) {
                            if (200 == res.code) {
                                if(res.data){
                                    $("#opBtn").show();
                                }else{
                                    $("#opBtn").hide();
                                }
                            }
                        }, 'GET');
                    }

                }
            })
        }

        // 显示编辑尽调弹窗
        function showDueEditModel(obj, data) {
            var index = admin.open({
                type: 1,
                area: ['80%', '80%'],
                offset: '85px',
                title: '详情',
                content: $('#agentAddDueForm').html(),
                success: function () {
                    let agentAddDueTableData = [];
                    admin.reqSync('enterprise/purchase/admin/supplierDueSubject/list', {
                        limit: 99999,
                        subId: data.categoryId
                    }, res => {
                        if (res.code === 200) {
                            data.subjectIdData = res.data;
                            res.data.forEach(item => {
                                if (item.id == data.subjectId) {
                                    data.subjectDetailData = item.paramValue.split(',')
                                }
                            })
                        } else {
                            data.subjectIdData = [];
                            data.subjectDetailData = [];
                        }
                    }, 'get', false);
                    // data.categoryIdData = arr2tree;
                    data.subjectDetailArr = [];
                    data.index = 0;
                    agentAddDueTableData = [data];

                    var agentAddDueTb = table.render({
                        elem: '#agentAddDueTable',
                        data: agentAddDueTableData,
                        page: false,
                        limit: Number.MAX_VALUE,
                        cellMinWidth: 100,
                        cols: [[
                            {field: 'categoryName', title: '尽调分类'}
                            , {field: 'subjectName', title: '尽调科目'}
                            , {
                                field: 'subjectDetail', title: '尽调评述', width: 300, templet: d => {
                                    let subjectDetailHtml = '<div class="subjectDetailBox">';
                                    if (d.subjectType == 'radio') {
                                        d.subjectDetailData.forEach((item, index) => {
                                            if (item == d.subjectDetail) {
                                                subjectDetailHtml += '<input type="radio" class="subjectType" name="subjectDetail' + d.index + '" title="' + item + '" value="' + item + '" checked lay-verify="otherReq">'
                                            } else {
                                                subjectDetailHtml += '<input type="radio" class="subjectType" name="subjectDetail' + d.index + '" title="' + item + '" value="' + item + '" lay-verify="otherReq">'
                                            }
                                        });

                                    } else if (d.subjectType == 'check') {
                                        let subjectDetailArr = d.subjectDetail;
                                        d.subjectDetailData.forEach((item, index) => {
                                            subjectDetailHtml += '<div style="display: inline" class="subjectDetailBoxList">';
                                            if (subjectDetailArr.includes(item)) {
                                                subjectDetailHtml += '<input type="checkbox" class="subjectType" title="' + item + '"  name="subjectDetail' + d.index + '"  value="' + item + '" checked lay-verify="otherReq">';
                                            } else {
                                                subjectDetailHtml += '<input type="checkbox" class="subjectType" title="' + item + '"  name="subjectDetail' + d.index + '"  value="' + item + '" lay-verify="otherReq" >';
                                            }
                                            subjectDetailHtml += '</div>'
                                        });

                                    } else {
                                        subjectDetailHtml +=  d.subjectDetail
                                    }
                                    subjectDetailHtml += '</div>';
                                    return subjectDetailHtml
                                }
                            }
                            , {
                                field: 'enclosure',
                                title: '附件',
                                width: 80,
                                align: 'center',
                                templet: d => d.enclosure?'<a class="layui-btn layui-btn-xs layui-btn-warm" href="' + d.enclosure + '" target="view_window">查看附件</a>':'无'
                            }
                            , { field: 'resultDesc', title: '结果'}
                            , {field: 'detail', title: '整体评估描述'}
                        ]],
                        done: function (res, curr, count) {
                            $('div[lay-id="agentAddDueTable"] input').attr('disabled', 'disabled');
                            $('div[lay-id="agentAddDueTable"] select').attr('disabled', 'disabled');
                            form.render('select');
                        }
                    });

                    /*  //加载供应商列表
                      admin.req('supplier/purchase/admin/supplierInfoPass/list', {limit: 99999}, function (res) {
                          loadSelectHtml(res.data, "请选择供应商", "purSupId", 1);
                          if (obj&&!dueFlag) {
                              $("#purSupId").html("<option>"+obj.data.corporateName+"</option>");
                              $("#purSupId").attr("disabled", '');
                              form.render('select');
                          }
                      }, 'get', false);

                      //加载尽调分类
                      var arr2tree;
                      admin.req('supplier/purchase/admin/supplierDueSubjectCategory/list', {limit: 99999}, function (res) {
                          for (let i = 0; i < res.data.length; i++) {
                              res.data[i].children = [];
                          }
                          arr2tree = xmSelect.arr2tree(res.data, "parentId", "id", "children", -1);
                      }, 'get', false);

                      var selectedData = function (treeData, targetId) {
                          for (var k = 0; k < treeData.length; k++) {
                              var nodeId = treeData[k].id;
                              if (targetId == nodeId) {
                                  treeData[k].selected = true;
                                  return;
                              } else {
                                  if (treeData[k].children && treeData[k].children != '') {
                                      selectedData(treeData[k].children, targetId);
                                  }
                              }
                          }
                      }

                      if (data) {
                          selectedData(arr2tree, data.categoryId);
                      }

                      var smlSelectInstans = xmSelect.render({
                          el: '#categoryIdDue',
                          model: {label: {type: 'text'}},
                          radio: true,
                          clickClose: true,
                          filterable: true,
                          tree: {
                              show: true,
                              strict: false,
                              expandedKeys: [-1],
                          },
                          tips: '顶级分类',
                          prop: {
                              name: 'name',
                              value: 'id',
                              children: 'children'
                          },
                          data() {
                              //填充数据
                              return arr2tree;
                          },
                          on(data) {
                              let parentId = data.arr.length > 0 ? data.change[0].id : -1;
                              $("input[name='categoryId']").val(parentId);
                          }
                      });
                      //加载尽调科目
                      admin.req('supplier/purchase/admin/supplierDueSubject/list', {limit: 99999}, function (res) {
                          loadSelectHtml(res.data, "请选择尽调科目", "subject1Id", 0);
                          loadSelectHtml(res.data, "请选择尽调科目", "subject2Id", 0);
                          loadSelectHtml(res.data, "请选择尽调科目", "subject3Id", 0);
                          if (data) {
                              $("#subject1Id").val(data.subject1Id);
                              $("#subject2Id").val(data.subject2Id);
                              $("#subject3Id").val(data.subject3Id);
                              form.render('select');
                          }
                      }, 'get', false);

                      $('#btnUpload19').click(uploadImg('btnUpload19', 'btnUpload19_path', 'fileUrl','fileName'))

                      if (data && data.enclosureList[0]) {
                          $('#btnUpload19_path').html('<span>'+ data.enclosureList[0].fileName +'</span>');
                          $('#fileUrl').val(data.enclosureList[0].fileUrl);
                          $('#fileName').val(data.enclosureList[0].fileName);
                      }
                      if(!dueFlag&&data){//显示详情 隐藏保存按钮
                          $('#supplierDueFormSubmit').css("display", "none")
                          $('[lay-filter="agentAddDueForm"] input').attr("disabled",'');
                          $('[lay-filter="agentAddDueForm"] select').attr("disabled",'');
                          $('[lay-filter="agentAddDueForm"] textarea').attr("disabled",'');
                          $('[lay-filter="agentAddDueForm"] input').attr("placeholder",' ');
                          $('#btnUpload19').css("display","none");
                          xmSelect.render({
                              el: '#categoryIdDue',
                              disabled: true
                          })
                      }

                      form.val('agentAddDueForm', data);

                      // 表单提交事件
                      form.on('submit(agentAddDueFormSubmit)', function (d) {
                          layer.load(2);
                          if(null != obj) {
                              d.field.purSupId = obj.data.id;
                          }
                          var attrArry = [];
                          var attrObj = {
                              fileUrl: $("#fileUrl").val(),
                              fileName: $("#fileName").val()
                          };
                          attrArry.push(attrObj);
                          d.field.enclosureList = attrArry;

                          admin.req(data ? 'supplier/purchase/admin/supplierDue/update' : 'supplier/purchase/admin/supplierDue/add', JSON.stringify(d.field), function (res) {
                              layer.closeAll('loading');
                              if (res.code == 200) {
                                  layer.msg(res.msg, {icon: 1});
                                  table.reload('agentDueTable');
                                  layer.close(index);
                              } else {
                                  layer.msg(res.msg, {icon: 2});
                              }
                          }, 'POST', true, 'application/json; charset=utf-8');
                          return false;
                      });*/

                }

            })
        }


        //尽调工具条点击事件
        table.on('tool(agentDueTable)', function (obj) {
            var data = obj.data;
            if (obj.event === 'dueEdit') { //修改
                showDueEditModel(null, data);
            } else if (obj.event === 'dueDel') { // 删除
                doDueDelete(obj);
            }else if (obj.event === 'dueCheck') { // 审核
                doDueCheck(obj);
            }else if (obj.event === 'dueDetail') { // 详情
                dueFlag=false;
                showDueEditModel(null, data);
            }
        });

        // 尽调删除
        function doDueDelete(obj) {
            layer.confirm('确定要删除吗？', {
                offset: '65px',
                skin: 'layui-layer-admin'
            }, function (i) {
                layer.close(i);
                layer.load(2);
                admin.req('enterprise/purchase/admin/supplierDue/' + obj.data.id, {}, function (res) {
                    layer.closeAll('loading');
                    if (res.code == 200) {
                        layer.msg(res.msg, {icon: 1});
                        obj.del();
                    } else {
                        layer.msg(res.msg, {icon: 2});
                    }
                }, 'DELETE');
                admin.req('enterprise/purchase/admin/supplierDueEnclosure/' + obj.data.id, {}, function (res) {
                    layer.closeAll('loading');
                    if (res.code == 200) {
                        layer.msg(res.msg, {icon: 1});
                        obj.del();
                    } else {
                        layer.msg(res.msg, {icon: 2});
                    }
                }, 'DELETE');
            });
        }

        // 尽调审核
        function doDueCheck(obj) {
            layer.confirm('确定要审核吗？', {
                offset: '65px',
                skin: 'layui-layer-admin'
            }, function (i) {
                layer.close(i);
                layer.load(2);
                admin.req('enterprise/purchase/admin/supplierDue/check?id=' + obj.data.id, {}, function (res) {
                    layer.closeAll('loading');
                    if (res.code == 200) {
                        layer.msg(res.msg, {icon: 1});
                        table.reload('agentDueTable');
                    } else {
                        layer.msg(res.msg, {icon: 2});
                    }
                }, 'GET');
            });
        }


        // 导出excel
        $('#supplierInfoBtnExport').click(function () {
            var checkRows = table.checkStatus('supplierInfoTable');
            if (checkRows.data.length == 0) {
                layer.msg('请选择要导出的数据', {icon: 2});
            } else {
                table.exportFile(insTb.config.id, checkRows.data, 'xls');
            }
        });


        // 模板下载
        $('#productDetailBtnTemplate').click(function () {
            window.location.href = config.base + 'enterprise/purchase/admin/supplierInfo/template';
        });
        //导入excel
        $('#uploaderInput').on('change', function (e) {
            layer.load(2);
            var formData = new FormData();
            var files = e.target.files;
            let that = $(this);
            formData.append('file', files[0]);
            formData.append('name', files[0].name); //这个地方可以传递多个参数
            $.ajax({
                url: config.base + 'enterprise/purchase/admin/supplierInfo/importExcel',
                data: formData,
                headers: { Authorization: 'Bearer ' + config.getToken() },
                type: 'POST',
                processData: false,
                contentType: false,
                success: function (res) {
                    layer.closeAll('loading');
                    if (res.code == 200) {
                        layer.msg(res.msg, { icon: 1 });
                        layer.closeAll('page');
                        setTimeout((_) => {
                            location.reload();
                        }, 1000);
                    } else {
                        layer.msg(res.msg, { icon: 2 });
                    }
                    that.val('');
                },
            });
        });



        $('#syncSupplierInfoBtn').click(function () {
            syncChangJieTongFunction();
        });

        function syncChangJieTongFunction() {
            layer.confirm('确定要同步供应商数据吗？', {
                offset: '265px',
                skin: 'layui-layer-admin'
            }, function (i) {
                layer.close(i);
                layer.load(2);
                admin.req('enterprise/purchase/admin/supplierInfoPass/syncGetSupplierList', {}, function (res) {
                    layer.closeAll('loading');
                    if (res.code == 200) {
                        layer.msg("操作成功", {icon: 1});
                    } else {
                        layer.msg(res.msg, {icon: 2});
                    }
                    table.reload('systemMsgCategoryTable');
                    layer.closeAll('page');
                }, 'GET');
            });
        }



    });
</script>